Readonly attribute doesn't work on Radio field

Support General Readonly attribute doesn't work on Radio field

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #31415
    ChrisLowranceChrisLowrance
    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',
                    ),
            ),
    #31418
    Long NguyenLong 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
    ChrisLowranceChrisLowrance
    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 NguyenLong 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 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.