Skip to content

Commit

Permalink
Merge pull request #61 from creative-commoners/pulls/3.2/solr-link
Browse files Browse the repository at this point in the history
FIX Check current controller has a functional link
  • Loading branch information
emteknetnz committed May 17, 2022
2 parents 7382314 + 78c875b commit 9f727d5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Model/ElementForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use SilverStripe\Control\Controller;
use DNADesign\Elemental\Models\BaseElement;
use DNADesign\ElementalUserForms\Control\ElementFormController;
use SilverStripe\Control\RequestHandler;

class ElementForm extends BaseElement
{
Expand Down Expand Up @@ -37,10 +38,16 @@ public function Form()
return $controller->renderWith(UserDefinedFormController::class .'_ReceivedFormSubmission');
}

// $current may not have a functional Link(), e.g. QueuedTaskRunner during solr reindex
// surpress E_USER_WARNING from RequestHandler::Link() if url_segment config missing
set_error_handler(fn(int $errno, string $errstr) => true, E_USER_WARNING);
$link = $current->Link();
restore_error_handler();

$form = $controller->Form();
$form->setFormAction(
Controller::join_links(
$current->Link(),
$link,
'element',
$this->owner->ID,
'Form'
Expand Down

0 comments on commit 9f727d5

Please sign in to comment.