Forums

Dynamic delete fields from form

benbeek 06 Jan, 2014
I use ChronoForms to edit a table with user data.
For some user I want to make it possible to edit all fields, for others only some fields.
How can I dynamically drop/delete specific fields from the form (eg delete them from the form->data[] array).

Ben.
GreyHead 06 Jan, 2014
Hi benbeek,

You can use a Custom Code action in the form ON Load event to edit the $form->data array and unset some values. But it might be better to either hide the inputs or set them to readonly or disabled instead.

Bob
benbeek 06 Jan, 2014
I tried that with a php onload event before the show html, eg:
unset($form->data['startdate']) ;

but this does not work. Field 'startdate' is still there.

So the question is (and was): how can I delete fields from the form? (or maybe disable or hide them).

Ben.
GreyHead 06 Jan, 2014
Hi Benbeek,

One simple solution is to put the optional inputs into a Custom Container and then add PHP to the Start box so that the container is only displayed if the user is 'approved'.

Bob
This topic is locked and no more replies can be posted.