i see in fieldType | Grocery CRUD there is checkbox_boolean field type. But how to use it ? i try like :
$crud->fieldType(‘field_name’, ‘checkbox_boolean’, [
‘N’ => ‘N’,
‘Y’ => ‘Y’,
]);
But doesn’t work. Can anyone help me ?
i see in fieldType | Grocery CRUD there is checkbox_boolean field type. But how to use it ? i try like :
$crud->fieldType(‘field_name’, ‘checkbox_boolean’, [
‘N’ => ‘N’,
‘Y’ => ‘Y’,
]);
But doesn’t work. Can anyone help me ?
Hello
I think you have an extra comma(,) here
‘Y’ => ‘Y’,
Hello @heruprambadi and welcome to our forums
The use of checkbox_boolean doesn’t take any options at the moment. So the use is as follows:
$crud->fieldType('field_name', 'checkbox_boolean');
Which only takes the arguments 0 or NULL (depends if your field is nullable) and 1 if checked.
This is currently hardcoded values and I would like to revisit it to be honest for Grocery CRUD version 3 which is removed for now. I guess your point is valid, to have custom values but maybe the field name also will be a different one such as checkbox
instead of checkbox_boolean
.
Regards
Johnny
$crud->fieldType(‘field_name’, ‘checkbox_boolean’, [
‘N’ => ‘No’,
‘Y’ => ‘Yes’,
]);
In this code, ‘field_name’ refers to the name of the field you want to use the ‘checkbox_boolean’ type for. The second parameter (‘checkbox_boolean’) tells Grocery CRUD that you want to use the checkbox boolean type. The third parameter is an array that maps the values that will be stored in the database (N and Y) to the labels that will be displayed in the interface (‘No’ and ‘Yes’ respectively).
If this still doesn’t work, please provide more details about the issue you are facing, such as error messages or unexpected behavior.
like johnny said above penn, it doesn’t take any options at the moment. Have you tried option :
[
‘N’ => ‘N’,
‘Y’ => ‘Y’,
]
it doesn’t do anything…
Ok thx john. I just need to label the checkbox, i think i will do it with callbackField.
How about radio button ? which field type i should use ?