How to use field type checkbox_boolean?

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 :hugs:

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 ?

Hello @heruprambadi ,

Glad to inform you that version 3.1.1 is now released and it is also including this change. The new field type is ‘boolean’. Let me know for any feedback :slight_smile:

Regards
Johnny

hello @johnny
i try to use like this :

$crud->fieldType('nama', 'boolean', [1 => 'Debet', 2 => 'Kredit']);

and the result is like this :
image

am i using it right ?

Hello @heruprambadi ,

Currently the ‘boolean’ is used like this:

$crud->fieldType('nama', 'boolean');

and have no options at the moment.

The output should look like the one that you have in the screenshot but I don’t know why it is not aligned. Do you have extra CSS for your bootstrap theme?

I guess you are interested about a new field ‘checkbox’ which could have two values right?

Regards
Johnny