#1 2018-06-19 14:20:20

Registered: 2015-05-19
Posts: 27

config/forms.php conditional field

Hi all,
I need your help to solve this problem.
I have a form within a view. The field of this form are all managed with if statement, depending on the fact that the editor has choose or not  to display every single field, with a content element called form-builder.
For example:
the content element has three field: name, surname, name+surname
the editor can choose to display the 1st and the 2nd, or just the 3rd
the view manage the fields: if editor has choose the first and the second, then the browser will display two fields, else if the editor has choose just the 3rd, the browser will display this 3rd field.

My question starts here: the config/forms.php manage the fields of the form and define wether a field is required or not. In my view I display all the possible fields of the form. But, if I define a field in the forms.php that the editor has not choose to display, what happens is that the form returns error cause there is a required field not filled.

What I'd like to know is if there is a way to manage conditional field in the forms.php. So the editor can choose not to display a field that is not required, but that would be required if displayed.

I've tried with a plain (if (isset($_POST["name-surname"]) && !empty($_POST["name-surname"])))  but the page return error of unexpected if.

I hope it's clear enough.
Thank you


What's Ionize ?

Ionize is an Open Source Content Management System created by webdesigners for webdesigners.

Created and maintained by Partikule and Toopixel, Ionize wants to be the easiest and most powerful CMS.

Can I help ?

Because talent is nothing without involvement, we are looking for motivated coders and webdesigners to join the project team.


Website : ionizecms.com
Documentation : doc.ionizecms.com

Development : Ionize on GitHub
Translations : Ionize Translations