Page 1 of 1
CSV magic fiile (option list)
Posted: 2021-12-23 10:09
by sacgtdev
For the list option using csv method, if the 'option 1' is removed from the csv. The previously entered value will not be shown in the form details. Re-saving the record will nullify the value.
Is there any tricks to circumvent the changes on the field to NULL during saving despite the original value option was removed from the csv?
Re: CSV magic fiile (option list)
Posted: 2021-12-23 20:30
by pbottcher
Hi,
I think this is a little bit tricky as you will have to know if the user did clear the field or the field is cleared as it is not available in the selectable items.
In case you know that the user does not clear the field you could use the before_update and after_update hooks.
In the before_update hook you check if the field value is NULL (in the $data array). If so, you retrieve the actual value for the selecedid and store it in a $_SESSION variable.
In the after_update hook you check if the $_SESSION variable has been set. If this is the case you can update the record with that value and unset the $_SESSION variable.
Hope that helps