Using form with two fieldsets inside

Hello everyone.
Any example of form with two fieldsets inside with filter and each fieldset is bind to an Object ?

Do you mean something like:

  • form: Album::class
    • fieldset: Artist::class
    • fieldset: Label::class

Yes. And I would like to know how to handle the form in the controller

Much like you would handle any other laminas form. Couple things to note. When passing data to the form via $form->setData($data) you will need to pass it an array with keys matching your fieldset names. When setting posted data, those keys will already be present if you use $form->setData($this->request->getPost()); Also of note I suppose is that, atleast for me, it was easier to have the fieldset implement InputFilterProviderInterface and provide a filter specification. I have went to the trouble of providing factories for all of my fieldsets and forms so that when using the FormElementManager I can call build and pass it options so the form and fieldsets can be context aware for including things like a role select for users that have privilege to modify a users role etc.

Thank you @Tyrsson , I have already found a solution.

1 Like