unset_fields after fields
- Single Page
Posted 16 May 2012 - 15:43 PM
I think I just stumbled upon a small bug:
According to some conditions, I sometimes want to unset some fields that I set before. I use grocery_crud->unset_fields for this. However, if I first set the field using grocery_crud->fields, unsetting it has no effect anymore. So:
...->grocery_crud->fields('a', 'b', 'c');
followed by
...->grocery_crud->unset_fields('b');
will still display 'b' in the add/edit screen.
For unset_columns / columns behavior is working as expected (so you can unset a column after first setting it).
Posted 16 May 2012 - 16:57 PM
[font=helvetica, arial, sans-serif][color=#282828]The purpose of the unset_fields is used for example if you have 15 fields at your database and you just want to unset two fields. [/color][/font]
[font=helvetica, arial, sans-serif][color=#282828]So before the creation of unset_field (before 1.2) you would write:[/color][/font]
[font=helvetica, arial, sans-serif][color=#282828]
[/color][/font]
$crud->fields('a','b','c','d',...'w','s');
[color=#282828][font=helvetica, arial, sans-serif]but now you can simply write: [/font][/color]
[font=helvetica, arial, sans-serif][color=#282828]
[/color][/font]
$crud->unset_fields('m','l');
[color=#282828][font=helvetica, arial, sans-serif]and that's it[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]Perhaps at a future release I will change it to be like unset_columns (so you can set and unset fields), but we can live without it [/font][/color][color=#282828][font=helvetica, arial, sans-serif] [/font][/color][color=#282828][font=helvetica, arial, sans-serif] [/font][/color]
Posted 16 May 2012 - 18:17 PM
Thanks to mention it.
Posted 16 May 2012 - 20:38 PM
Posted 16 May 2012 - 20:56 PM
For now a let's name it "work around" for your situation is this:
$this->fields('test1','test2','test3'); //'test4','test5','test6'
what do you think?