Custom Fields
Re-Envisioned
Support General Readonly attribute doesn't work on Radio field

  • Creator
    Topic
  • #31415
    ChrisLowrance
    Participant

    Hi,

    On radio fields, setting the attribute "readonly" to true has no effect. Options can still be selected and saved. Is this a known issue? Thanks!

    array(
                'name'    => 'Test',
                'id'      => 'test',
                'type'    => 'radio',
                            'readonly' => true,
                            'options' => array(
                     '1' => '1',
                    '2' => '2',
                    ),
            ),
Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #31418
    Long Nguyen
    Moderator

    Hi,

    The attribute readonly does not work with the field radio. You can set the default value and disable the radio field.

              [
                'name'     => __( 'Radio', 'your-text-domain' ),
                'id'       => $prefix . 'radio',
                'type'     => 'radio',
                'options'  => [
                  'a' => __( 'A', 'your-text-domain' ),
                  'b' => __( 'B', 'your-text-domain' ),
                  'c' => __( 'C', 'your-text-domain' ),
                ],
                'std'      => 'b',
                'disabled' => true,
              ],
    #31529
    ChrisLowrance
    Participant

    Thanks for confirming!

    "Disabled" won't work for this case - we're deprecating an existing field. We want to prevent users from changing them, but still display the existing value if already set.

    I'll find a workaround. Thanks!

    #31535
    Long Nguyen
    Moderator

    Hi,

    You can try to get the current field value and assign it to the std setting if the value is already set. Refer to this tutorial https://docs.metabox.io/save-wysiwyg-content-post-content/

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.