Select / Select advanced read-only/disabled

Support General Select / Select advanced read-only/disabled

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #38248
    Jean-Michel JunodJean-Michel Junod
    Participant

    Metabox AIO v.1.16.4
    Using Metabox Builder for custom fields for USER.
    Problems with read-only/disabled and saving values:

    Select field:
    read-only: it is still possible to change value and save it
    disabled: current value is lost after saving

    Select advanced (same):
    read-only: it is still possible to change value and save it
    disabled: current value is lost after saving

    Input field also loose value after saving if "disabled".

    Feature request for input/select fields:
    - property "protected" or "locked" that would replace the field value with just a <div class="rwmb-input">[value]</div> or something that would prevent user to inspect/edit page html and update disable/readonly attributes

    #38257
    sherwin_flightsherwin_flight
    Participant

    You can use some JavaScript to remove the disabled attribute when you save, and then the values will be saved as expected.

    But I think a read only/locked option would be great. I'm struggling with a similar issue right now as well, only with clone groups that i want to be read only.

    #38260
    Long NguyenLong Nguyen
    Moderator

    Hi,

    For the select field, you can use the setting disable to prevent the user from selecting the option and set the default value for the field to save the field value to the database. For example:

    [
        'name'     => __( 'Select', 'your-text-domain' ),
        'id'       => 'select_67b3inmhfgs',
        'type'     => 'select',
        'options'  => [
            'a' => __( 'A', 'your-text-domain' ),
            1   => __( '1', 'your-text-domain' ),
            2   => __( '2', 'your-text-domain' ),
            3   => __( '3', 'your-text-domain' ),
        ],
        'std'      => 2,
        'disabled' => true,
    ],
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.