How to Create Custom Columns Value

Hi ,
i want create custom columns to display a custome text depend on the value
for ex… the column for user active , and this table filed conaine integer value 1 or 0 , so when the value is 1 it will show text (Activated) in the column value …
how i can do it ?

1 Like

Hello there
Maybe you do not understand your problem well, but if the issue is in true-false values

Field Type
Field Type 1.x
Field Type 2.x

Hi @wesambeshir!

For this you can either use field types or set relation whichever is convenient for you. Take note that in set relation, it would require you to create another table wherein your data would relate to.

For fieldtypes using GroceryCRUD Community Edition you can do this:
(It is assumed here that your field name was “useractive”)

$crud->field_type('useractive','dropdown',
            array('0' => 'Inactive', '1' => 'Active'));

For fieldtypes using GroceryCRUD Enterprise Edition you can do this:
(It is assumed here that your field name was “useractive”)

$crud->fieldType('useractive', 'dropdown_search', [
    '0' => 'Inactive',
    '1' => 'Active'
]);

For set relation using GroceryCRUD Community Edition you can do this:
(It is assumed here that you have a table called tblboolean and it has a field called bool_Name which contains records: Inactive and Active)

$crud->set_relation('useractive_id','tblboolean','bool_Name');

For set relation using GroceryCRUD Enterprise Edition you can do this:
(It is assumed here that you have a table called tblboolean and it has a field called bool_Name which contains records: Inactive and Active)

$crud->setRelation('useractive_id','tblboolean','bool_Name')

I hope this helps you out :blush:

1 Like