Skip to content

Commit

Permalink
fix: added support for multiple form elements on one page
Browse files Browse the repository at this point in the history
  • Loading branch information
rasstislav committed Sep 27, 2023
1 parent 9ab97a3 commit f5d2927
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/Control/ElementFormController.php
Expand Up @@ -70,9 +70,17 @@ public function finished()
*/
public function Link($action = null)
{
$id = $this->element->ID;
$segment = Controller::join_links('element', $id, $action);
$page = Director::get_current_page();
$id = $this->element->ID;

if ($this->getAction() === 'finished'
&& $action !== 'finished'
&& $this->getRequest()->param('ID') == $id
) {
$segment = $action;
} else {
$segment = Controller::join_links('element', $id, $action);
}

if ($page && !($page instanceof ElementController)) {
return $page->Link($segment);
Expand Down
5 changes: 3 additions & 2 deletions src/Model/ElementForm.php
Expand Up @@ -32,9 +32,10 @@ public function Form()
{
$controller = UserDefinedFormController::create($this);
$current = Controller::curr();
$controller->setRequest($current->getRequest());
$request = $current->getRequest();
$controller->setRequest($request);

if ($current && $current->getAction() == 'finished') {
if ($current && $current->getAction() == 'finished' && $request->param('ID') == $this->ID) {
return $controller->renderWith(UserDefinedFormController::class .'_ReceivedFormSubmission');
}

Expand Down

0 comments on commit f5d2927

Please sign in to comment.