⚠ 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

Callback coloumn value



Hasan Busro

Hasan Busro
  • profile picture
  • Member

Posted 04 April 2013 - 06:32 AM

Hallo, grocerycrud is best app for CI.

I have question.

 

I will create callback coloumn with rule like this:

I have table with filed name is status (integer),

If value of status=0 this equal "false" then in coloum displaying "false",

and if value of status=1 this equal "true" then in coloumn displaying "true".

 

How to do it.?

 

Thank you very much


Zalo

Zalo
  • profile picture
  • Member

Posted 04 April 2013 - 16:46 PM

The easiest and most automatic way to do this is to use a tinyint(1) instead of integer in the database. That way, GC automatically assumes it is a true/false value.

The second way is to set it manually, field_type() should do the trick.

 

Something like this:

 

$crud->field_type('your_field_name','dropdown', array('1' => 'True', '0' => 'False'));

 

 

With that, you get a dropdown on your forms (add and edit) and the column get's it's value accordingly to what you have setted.

 

Hope it helped! 


Hasan Busro

Hasan Busro
  • profile picture
  • Member

Posted 06 April 2013 - 00:41 AM

The easiest and most automatic way to do this is to use a tinyint(1) instead of integer in the database. That way, GC automatically assumes it is a true/false value.

The second way is to set it manually, field_type() should do the trick.

 

Something like this:

 

$crud->field_type('your_field_name','dropdown', array('1' => 'True', '0' => 'False'));

 

 

With that, you get a dropdown on your forms (add and edit) and the column get's it's value accordingly to what you have setted.

 

Hope it helped! 

OK This works. Thank you very much