I have a CakePHP form with radio buttons that enhance the frontend by toggling form sections on and off. To make the radio buttons work, I need a name attribute that binds them together.
However, my problem is that CakePHP POSTs any input field with a name attribute, so the radio button above causes errors when submitting the form because I don't have a toggle-0
field in my model.
Is there a way to prevent CakePHP from posting the radio button values? Can I achieve this in the frontend or backend?
This seems like a very simple thing to do (Like in C# MVC) but I can't seem to find any information on the Cake Cookbook.
Relevant Radio Button:
<input id="toggle-on-0" class="selection-toggle selection-toggle-left" name="toggle-0" value="false" type="radio">
<label for="toggle-on-0" class="selection-btn">On</label>
<input id="toggle-off-0" class="selection-toggle selection-toggle-right" name="toggle-0" value="true" type="radio">
<label for="toggle-off-0" class="selection-btn">Off</label>
Let me know if I can clarify the question or if you need the code for my add()
method.