'Switch' Element Cannot be Defaulted to "On" within MB Group "Clones"

Support MB Group 'Switch' Element Cannot be Defaulted to "On" within MB Group "Clones"Resolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #47452
    CodogCodog
    Participant

    Hi there,
    I believe that the Switch custom field element when used as MB Group subfield cannot be set to the default "On" status when "cloned".

    When a MB Group subfield Switch element uses the 'std' => true, attribute the FIRST subfield group element respects the attribute and the default "On" status is set. Subsequent MB Group subfield clones DO NOT respect the 'std' => true, attribute.

    To Re-Create:
    =============

    1) Create a new 'type' => 'group', custom field ensuring that 'clone' => true, is set.
    2) Add some sub-fields ensuring that you include the following Switch element within them:

    
    [
    'id'        => 'enable_switch',
    'name'.     => 'Enable This',
    'type'      => 'switch',
    'style'     => 'square',
    'on_label'  => 'Enabled',
    'off_label' => 'Disabled',
    'std'   => true, // Default On
    ],
    

    3) Test the new group subfields clone creation and observe the switch status.

    I can confirm that...

    1) The issue is present in both a MB Frontend Submission Form and in the WP-ADMIN when creating group clones.
    2) The issue is present with either 'clone_empty_start' => true, OR 'clone_empty_start' => false, within the group settings.

    Q) Is this expected behaviour?
    Q) Can you also re-create this scenario?

    I look forward to your response.

    #47473
    PeterPeter
    Moderator

    Hello,

    If you want to show the ON switch as the default value for the cloneable entry, please enable the setting "Clone default value" for the group field. Please read more about the cloneable feature in the documentation https://docs.metabox.io/cloning-fields/
    and check this screen record https://imgur.com/vO3SxT6

    #47478
    CodogCodog
    Participant

    Hi Peter,
    perfect! Not sure how I missed that...doh!

    Thanks.

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