Forums

Edit form at certain conditions

fasenderos 01 Mar, 2015
Hello
I would give edit permissions at certain conditions.
i have two form, the first create an item and the second edit the item..
By now all fields are always editable.
The conditions to edit depending on time passed from the creation, so:
If less than 1 hour -> all editable
If beetwen 1 an 24 hours -> only some fields are editable
More than 24 hours -> deny edit.

Are the Custom Container useful to achieving this result?
Is the best way?
Thanks in advance
GreyHead 01 Mar, 2015
Hi fasenderos,

Hard to know the best way without seeing more detail about the form.

You need to set the readonly or disabled properties of the inputs to stop them being editable. The simplest way of doing this would be to use JavaScript - you can set a var depending on the time then use a switch statement to enable/disable the appropriate inputs.

Alternatively you could group the elements together and use Containers where the whole container is shown/hidden depending on the time. I can't think of any easy way to dynamically set input attributes individually.

Bob
fasenderos 01 Mar, 2015
Answer
Hi bob,
Thanks for reply.
I prefer to avoid JavaScript for security reasons, never trust the clients🙂
For now I use 3 Custom Containers with inside the editable elements and in "Start code" <?php if (some_conditions) : ?>
"End code" <?php endif; ?>
This seems to work as expected.
fasenderos
This topic is locked and no more replies can be posted.