CSV magic fiile (option list)

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
Veteran Member
Posts: 75
Joined: 2020-06-10 11:14

CSV magic fiile (option list)

Post by sacgtdev » 2021-12-23 10:09

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?

AppGini Super Hero
AppGini Super Hero
Posts: 1604
Joined: 2018-04-01 10:12

Re: CSV magic fiile (option list)

Post by pböttcher » 2021-12-23 20:30


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
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Post Reply