Custom Fields
Re-Envisioned
Support General Set Selected by default in Radio box

This topic contains 5 replies, has 3 voices, and was last updated by  Anh Tran 4 months, 2 weeks ago.

  • Creator
    Topic
  • #4415

    MD3
    Participant

    I have this code

    array(
    				'id'      => $prefix.'featured_product',
    				'name'    => 'Featured Product',
    				'type'    => 'radio',
    				'options' => array(
    					'yes' => 'Yes',
    					'no'  => 'No',
    				),
    			),

    I want to make “No” as selected by default.. how to do it?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
    Replies
  • #4431

    Anh Tran
    Keymaster

    Just add 'std' => 'no' to the field 😉

    #14722

    Nuno Cruz
    Participant

    I did not understand
    I have an input of type radio:
    Man (x) Woman (_)
    How do I do this?

    #14724

    Anh Tran
    Keymaster

    Hi Nuno,

    You just need to define the field like this:

    array(
      'id' => 'field_id',
      'name' => 'Gender',
      'options' => array(
        'm' => 'Man',
        'w' => 'Woman',
      ),
      'std' => 'm',
    )
    #14726

    Nuno Cruz
    Participant

    Not work 🙁

    array (
        'id' => 'sexo',
        'name' => 'Sexo',
        'type' => 'radio',
        'std' => 'Homem',
        'options' => array(
            'Homem' => 'Homem',
            'Mulher' => 'Mulher',
        ),
        'required' => 1,
    ),
    #14746

    Anh Tran
    Keymaster

    Probably, you’re on an old post or your meta box has already been saved. See this for more details:

    https://docs.metabox.io/field-settings/#default-value

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.