Coder Perfect

If I nest a SelectionGroup inside a FieldGroup, the Radio Box for one of the connected SelectionGroup Items does not appear. Why?

Problem

I have a form with two FieldGroups and a SelectionGroup in one of the FieldGroups.

The SelectionGroup Items appear in the FieldGroup form, but the radio buttons to choose one of the possibilities do not. It works again if I remove the FieldGroup.

I examined at the framework templates and found that if I change FieldGroup holder.ss SmallFieldHolder to FieldHolder, the radio boxes appear and function properly again. I’ve tried following the templates to discover which one doesn’t follow the SelectionGroup, but I’m getting nowhere.

Here’s a snippet of code as an example.

$fields = FieldList::create(
    FieldGroup::create(
        TextField::create('Name', 'Name')
    ),
    FieldGroup::create(
        SelectionGroup::create(
            'Test1or2',
            array(
                SelectionGroup_Item::create(
                    'Test1', array(
                        TextField::create('Test1', 'Test1')
                    ),
                    'Test1'
                ),
                SelectionGroup_Item::create(
                    'Test2', array(
                        TextField::create('Test2', 'Test2')
                    ),
                    'Test2'
                )
            )
        )
    )
),
FieldList::create(
    FormAction::create('submit', 'Submit')
)

Asked by Rudiger

Solution #1

You could add another fieldset and give it the id=”hidden field” and aria-hidden=”true” attributes. You might perform the following in the CSS document.

    #hidden_field{
        display:none;
        height:0;
        width:0;
        margin:0;
        padding:0;
        visibility: hidden;
    }

The query behavior of SilverStripe Framework should be hidden as a result of this. In my own php forms I had random brackets appearing whenever someone submitted a new form numerous times under different part-id numbers. I used this approach to hide the random brackets on my site.

Answered by JTS

Post is based on https://stackoverflow.com/questions/42334986/silverstripe-php-forms-if-i-nest-a-selectiongroup-inside-a-fieldgroup-one-of