# Using form with two fieldsets inside

**URL:** <https://discourse.laminas.dev/t/using-form-with-two-fieldsets-inside/2700>\
**Category:** Components & MVC\
**Tags:** laminas-form\
**Created:** [January 10, 2022, 5:36am UTC](https://discourse.laminas.dev/t/using-form-with-two-fieldsets-inside/2700 "2022-01-10T05:36:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ebuddy](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/ebuddy/32/1536_2.png) [@ebuddy](https://discourse.laminas.dev/u/ebuddy)\
**Post date:** [January 10, 2022, 5:36am UTC](https://discourse.laminas.dev/t/using-form-with-two-fieldsets-inside/2700/1 "2022-01-10T05:36:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [January 25, 2022, 10:09am UTC](https://discourse.laminas.dev/t/using-form-with-two-fieldsets-inside/2700/2 "2022-01-25T10:09:19Z")

</div>

Do you mean something like:

- form: Album::class
  - fieldset: Artist::class
  - fieldset: Label::class

---

<div class="post-metadata">

**Author:** ![ebuddy](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/ebuddy/32/1536_2.png) [@ebuddy](https://discourse.laminas.dev/u/ebuddy)\
**Post date:** [January 25, 2022, 10:56am UTC](https://discourse.laminas.dev/t/using-form-with-two-fieldsets-inside/2700/3 "2022-01-25T10:56:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Tyrsson](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/tyrsson/32/1664_2.png) [@Tyrsson](https://discourse.laminas.dev/u/Tyrsson)\
**Post date:** [April 7, 2022, 2:34am UTC](https://discourse.laminas.dev/t/using-form-with-two-fieldsets-inside/2700/4 "2022-04-07T02:34:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ebuddy](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/ebuddy/32/1536_2.png) [@ebuddy](https://discourse.laminas.dev/u/ebuddy)\
**Post date:** [May 23, 2022, 1:33am UTC](https://discourse.laminas.dev/t/using-form-with-two-fieldsets-inside/2700/5 "2022-05-23T01:33:20Z")

</div>

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