Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Multiple forms on one page

How to add multiple forms on one page? This works, but all the forms validate at once. How to validate only one and not show errors in others?



668
Accepted
answer

Ok, at this moment I create hidden field in each form definition:

$this->addHidden('formType', $className);

In controller I check formType value from request: ```

if ($this->request->getPost('formType') == 'Form1') { if ($form1->isValid(null, true)) { } }

if ($this->request->getPost('formType') == 'Form2') { if ($form2->isValid(null, true)) { } }