120

I have a form that has two FieldGroups, and in one of the FieldGroups I have a SelectionGroup.

The SelectionGroup_Items show up in the form FieldGroup but the radio boxes to select one of the options doesn't show. If I remove the FieldGroup it then works again.

I've looked at the framework templates, and if I change the FieldGroup_holder.ss SmallFieldHolder to FieldHolder the radio boxes appear again and work correctly. I've tried following the templates to see which one isn't obeying the SelectionGroup but I keep getting lost.

Here's an example bit of code

$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')
)
Rudiger
  • 6,515
  • 13
  • 48
  • 94
  • 6
    Seems like SelectionGroup doesn't have a `SelectionGroup_small.ss` template which is used when you nest fields. Just create it in your theme and modify it. Could also be worth raising an issue on [github](https://github.com/silverstripe/silverstripe-framework/issues) – wmk Feb 20 '17 at 07:23
  • 1
    @wmk not having much luck with that. Anything else I can do to make it work? – Rudiger Feb 20 '17 at 10:28
  • adding `->setSmallFieldHolderTemplate('SelectionGroup_small')` to the `SelectionGroup` starts to fix it however using the markup from `SelectionGroup` doesn't fix the issue (thought it would look odd but be somewhat functional, it brings back the radio boxes but none of the fields beneath work). – Rudiger Feb 22 '17 at 08:50
  • 1
    I've also added a git issue https://github.com/silverstripe/silverstripe-framework/issues/6637 – Rudiger Feb 22 '17 at 08:58
  • Already old item but perhaps still curious: What is the result as source-code? In general it's possible that the fields are all in the source, but just hidden for some formatting reasons. – David Apr 17 '18 at 16:17
  • Sorry @David I'm a bit lost with your question. – Rudiger Apr 19 '18 at 06:09
  • @Rudiger I just meant what was the produced HTML? – David Apr 20 '18 at 08:58
  • @David Oh, I can't remember but it wasn't in the generated HTML, think it was a div for the button but no content inside it that I would have expected. – Rudiger Apr 21 '18 at 05:14
  • 1
    This is not a great question, and I don't know how it garnered 57 upvotes, especially given the low view count, but I guess it's not going anywhere because of that. Your problem is with the generated HTML, but you don't provide it, or provide an example of the desired HTML output. Your code sample is syntactically invalid, and no context is provided as to where it is used. If you solved this somehow, you should post an answer; if the problem is no longer relevant or reproducible, you should delete the question. – miken32 Mar 06 '19 at 17:11
  • 6
    @miken32 it's to do specifically with the SilverStripe framework (hence the tag) and a bug has been posted on the GitHub repository (linked in the comments). The reason there is no html is because there is no html template for the given functions, that is the bug. Besides a semi colon at the end I've got no idea what you're talking about it being syntactically invalid. Anyone who is familiar with the framework will know the context for it. It is still an open bug and easily reproducible. – Rudiger Mar 07 '19 at 03:54

1 Answers1

1

You could add another fieldset then set it's attributes to id="hidden_field" aria-hidden="true". In the css document you could do the following.

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

This should hide SilverStripe Framework's query behavior. 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.

JTS
  • 33
  • 10