unset_fields and callbacks
- Single Page
Posted 31 December 2012 - 13:00 PM
I have the following situation that I am not sure how to overcome - hope someone can help?
I have a user table, and it contains a column called "salt", which must be set when the user submits the form, but must not actually be in the edit or add screens, but calculated in a callback.
So, I use before_insert and before_update in callbacks to generate the salt before insert, but because I have disabled the "salt" field in the edit/add forms, the generated value for the salt never gets saved. I tested it by saving the salt in a field that is NOT unset, and then it works. So the problem is with the fact that the fields are unset in the add/edit screens.
How do I get around this?
Thanks in advance,
Kobus
Posted 02 January 2013 - 09:07 AM
Anybody with some info here?
Thanks!
Kobus
Posted 07 January 2013 - 14:41 PM
Anybody with an answer for me here, please? This is causing me a big problem, and I am sure I am just doing something stupid here.
Thanks in advance,
Kobus
Posted 08 January 2013 - 08:12 AM
You want to simply use the "invisible" field and not to unset the field. For these cases I create a type name invisible. You can find more at: http://www.grocerycr...invisible-field
As I also mention in the documentation:
[quote]This will NOT work as expected unless you add the invisible field so you have to do it like this:
$crud->fields('field1','field2','field3','field4');
$crud->field_type('field4','invisible');
$crud->callback_before_insert(array($this,'test_callback'));
[/quote]
The reason that "invisible" fields exists is mainly for security reasons.
Kindest Regards
Johnny
Posted 08 January 2013 - 16:18 PM
Kobus