Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Not using WordPress checked function? #139

Closed
turtlepod opened this Issue · 4 comments

5 participants

@turtlepod

i just try this, very cool.

i try using check-box and i think it's better if:

  1. using checked function.
    http://codex.wordpress.org/Function_Reference/checked

  2. save the vield with "1" and not "on"
    just like every admin checkbox in WordPress.

it's simple:
just change:


echo '<input type="checkbox" name="', $field['id'], '" id="', $field['id'], '"', $meta ? ' checked="checked"' : '', ' />';

to:

echo '<input type="checkbox" value="1" name="'.$field['id'].'" '. checked( ! empty( $meta ),true ,false ) .' />';

just a suggestion.

regards,
david.

@jaredatch
Collaborator

I completely agree. The issue now is just if and how to change so that it has some backwards compatibility. Or I suppose we could just not worry about that :P

@turtlepod

i don't think backwards compability is an issue.
as long as user don't check if the meta field == 'on'. or something like that.
and i think WordPress read the value of "0" is the same as no field entry. (maybe, i'm not really sure)

(sorry for my english, it's not my native language)

@Firestorm-Graphics

could this apply to radios too????

@sciamannikoo

I think that for backward compatibility it would be better to add an option where to set the value for selected checkbox.

Something like that:

                array(
                    'name' => __( 'My Field Label', 'textdomain' ),
                    'desc' => __( 'My Field description.', 'textdomain' ),
                    'id'   => $prefix . 'my_field',
                    'type' => 'checkbox',
                    'value' => '1', // Default 'on'
                ),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.