How to exclude 'buttons' from forms
Created 6 years ago by kiltedup

Hi, I am trying to add a form where there is only a single action (submit) and no buttons. However in the form builder, if I do not include protected $buttons, I get the default 'Cancel' button. If I add protected $buttons = [] then I get an error : "Method Anomaly\Streams\Platform\Ui\Form\FormCriteria::__toString() must not throw an exception, caught ErrorException: Invalid argument supplied for foreach()" Looking at the User Login and Register form builders as an example, I can see that they have one single action and no buttons but I can't for the life of me work out how to do that in my form !!! Any pointers appreciated. Dave

ryanthompson  —  6 years ago

Ya looking at the logic that is a little aggressive.. One thing you can do is this within the built callback:

And do something like this:

$builder->getForm()->getButtons(); // This will be the button collection where you can loop and forget($key) on the collection

Not the best.. but I will have to figure something out to preserve BC and make this easier to do in the meanwhile!