⚠ 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

Set a field to '0' with change_field_type



kaosweaver
  • profile picture
  • Member

Posted 15 June 2012 - 16:19 PM

I need to set a flag (0 or 1) depending on if they've been exported and, on updates, reset back to 0... so I put:

$crud->change_field_type('exported', 'hidden', '0');
or
$crud->change_field_type('exported', 'hidden', 0);

and the form retains the original exported value. I replaced with another number (2) and it worked as expected by populating the field with 2 - how do I get this to work as I need it to?

Thanks

kenvogt
  • profile picture
  • Member

Posted 15 June 2012 - 19:13 PM

It is possible there is a bug in ./libraries/grocery_crud.php around line 56 where it says:


if($this->change_field_type != null && isset($this->change_field_type[$field_info->name]))

It should perhaps read:


if($this->change_field_type !== null && isset($this->change_field_type[$field_info->name]))

(Note the !== rather than !=)

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

Posted 16 June 2012 - 16:21 PM

yes this is a bug ( https://github.com/scoumbourdis/grocery-crud/issues/65 ) . Grocery CRUD doesn't handle well values that equals with 0 as it recognize it as null. Probably it is something simple as [member='kenvogt'] mentioned. This will be fixed at the next version of grocery CRUD. For further news I will inform you.