⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

unset_fields and callbacks



Kobus
  • profile picture
  • Member

Posted 31 December 2012 - 13:00 PM

Hi all,

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

Kobus
  • profile picture
  • Member

Posted 02 January 2013 - 09:07 AM

Hi again,

Anybody with some info here?

Thanks!

Kobus

Kobus
  • profile picture
  • Member

Posted 07 January 2013 - 14:41 PM

Hi,

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

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 08 January 2013 - 08:12 AM

Kobus,

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

Kobus
  • profile picture
  • Member

Posted 08 January 2013 - 16:18 PM

Thanks, Johnny - as always, right on the money. Thanks!

Kobus