Replies: 2 comments 2 replies
-
I'm using |
Beta Was this translation helpful? Give feedback.
1 reply
-
Hi @dcoding1, I think you need the CheckBox::make('page.visible')
->sendTrueOrFalse()
->title('Visible')
->help('if a page visible'), HTML forms are not submitted by default if they are unchecked: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, i have strange checkbox behavior.
What i have :
a checkbox :
CheckBox::make('page.visible') ->title('Visible') ->help('if a page visible'),
field defined in db as :
$table->boolean('visible')->default(false);
After saving a form, i get data :
$data = $request->get('page');
Case 1 : If checkbox was checked (db value=1) and i uncheck it and then send, works correct (no values passed).
Case 2 : If checkbox was unchecked (db value=0) and I check it and then send, works incorrect ( value=0 )
But, if I add casting to the model, Case 2 starts working correct, but value = 'on' instead of '1' :
protected $casts = [ 'visible' => 'int' ];
Case 3 : Checkboxes without model field always have value 'on'.
Anybody knows why so ?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions