Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkbox default value #99

Closed
ceroz opened this issue Dec 6, 2013 · 2 comments
Closed

Checkbox default value #99

ceroz opened this issue Dec 6, 2013 · 2 comments

Comments

@ceroz
Copy link

ceroz commented Dec 6, 2013

$my_meta->addCheckbox('1_checkbox_field_id',array('name'=> 'My Checkbox 1'));
$my_meta->addCheckbox('2_checkbox_field_id',array('name'=> 'My Checkbox 2'));
$my_meta->addCheckbox('3_checkbox_field_id',array('name'=> 'My Checkbox 3'));
$my_meta->addCheckbox('4_checkbox_field_id',array('name'=> 'My Checkbox 4'));

I would like to set default value for these boxes. How this should be written ?

Tried following ways:
'std'=> 'checked'
'std'=> "checked"
'std'=> checked
'std'=> 'true'
'std'=> "true"
'std'=> true

After I disable or enable checkbox the value won't save.

Edit:
'std'=> false - save function works fine but only when I set it to "false". If i type here "true" it won't save the value.

For example:
$my_meta->addCheckbox('1_checkbox_field_id',array('name'=> 'My Checkbox 1', 'std'=> true));

In the admin panel I can see checked box, seems to be working but when i try to uncheck the box and save the value will rollback to "true" (checked)

@murilopolese
Copy link

Maybe you should try addCheckboxList instead.
https://github.com/bainternet/My-Meta-Box/blob/master/class-usage-demo.php#L94

@bainternet
Copy link
Owner

closed in favor of #102

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants