Closed jaynoe closed 10 months ago
You should use a function like described here: https://github.com/codefog/contao-haste/blob/main/docs/Form.md#preparing-a-form-instance
$form->setActionFromPageId($model->jumpTo);
Yeah, i was following the guide. I changed it to $form->setActionFromPageId = $model->jumpTo
but the action is still the initial request uri.
Nevermind its working now, dont know why - i changed it to this:
form->setAction(PageModel::findById($model->jumpTo)->getFrontendUrl());
It did not work because you tried to assign a non-existing property instead of using a function:
$form->setActionFromPageId = PageModel::findById($model->jumpTo)->id;
should become:
$form->setActionFromPageId(PageModel::findById($model->jumpTo)->id);
and even better:
$form->setActionFromPageId($model->jumpTo);
I created a FrontendModule Controller, where i build a custom form via the Form-Builder. Now i want to change the
action
value - but nothing happens. Here is the part of the code:Also in PHP 8.2 you get a deprecated notice by using the
setAction:
orsetActionFromPageId
function:Property declared dynamically, this is deprecated starting from PHP 8.2
But i guess the functions should work despite the deprecated note. Also you can set a attribute to prevent the notice - just for information