Jump to content

How to organize Fields in Fieldsets with the ModuleConfig->add() method?


horst
 Share

Recommended Posts

As the subject says.

With the ModuleConfig, we can define our fields in the MyModuleConfig.php __construct() method with calling $this->add() and pass it an array with lots of field-definition arrays. This is working fine with fields on one level. But how can I organize them into fieldsets?

I have tried a bit with multidim arrays, but no luck.

Has anyone does this before? Is anyone using this "new" config method? (implemented in PW 2.5.5)

:)

Link to comment
Share on other sites

Ah, great. I figured it out myself!

We need to add all fields into a children array:

$this->add(
array(
    array(
        'type' => 'Fieldset',
        'name' => '_myfieldset',
        'label' => 'Fieldset Label',
        'collapsed' => Inputfield::collapsedYes,  // Inputfield::collapsedNo
        'children' => array(
            array(
                'type' => 'select',
                'name' => 'kit_type',
                'label' => 'Select the Kit you are using',
                'options' => array('uikit' => 'uikit'),
                'required' => true,
                'columnWidth' => 50,
            ),
            array(
                'type' => 'text',
                'name' => 'kit_fullpath',
                'label' => 'directory site path to your kits scss sources',
                'columnWidth' => 50,
            )
        ), // close children
    ), // close fieldset

    //.. add more fields
));
  • Like 4
Link to comment
Share on other sites

Nope, sorry. For me that is to 'decoupled'.

Hhhm, yes! For me it is it a bit too. But I thought to try it out and maybe it is lesser code to write. We will see how it goes. :)

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...