Relationship field ignores "max_clone" setting

Support MB Relationships Relationship field ignores "max_clone" settingResolved

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #45042
    EugeneEugene
    Participant

    Hi,

    Why the relationship field ignores the "max_clone" setting?
    "+ Add" button and drag/sort handle still there.
    Maybe some other settings needs to be specified?

    
    add_action( 'mb_relationships_init', 'tickets_to_event_relationship' );
    
    function tickets_to_event_relationship() {
        MB_Relationships_API::register( [
            'id'   => 'tickets-to-event',
            'from' => [
                'object_type'   => 'post',
                'post_type'     => 'ticket',
                'meta_box' => [
                    'context'   => 'normal',
                    'priority'  => 'high',
                ],
            ],
            'to'   => [
                'object_type'   => 'post',
                'post_type'     => 'poster',
                'meta_box' => [
                    'context'   => 'normal',
                    'priority'  => 'high',
                    'closed'    => true,
                ],
                'field' => [
                    <strong>'max_clone' => '1',</strong>
                    'required'  => true,
                ],
            ],
        ] );
    }
    
    #45043
    EugeneEugene
    Participant

    Sorry, actual code doesn't contain "strong" tags. Just wanted to highlight the problem setting.

    'field' => [
                    'max_clone' => '1',
                    'required'  => true,
                ],

    p.s. by the way, where is the post edit button?)

    #45052
    PeterPeter
    Moderator

    Hello Eugene,

    It works well on my site. You can see the max_clone works when editing/creating a poster post, not ticket post.

    #45057
    EugeneEugene
    Participant

    Strange, it just doesn't work properly and ignores this option even though all the settings appear to be correct.
    This is a local installation and I can’t share the login credentials so you can investigate the problem, I’ll try to do it on staging. All other custom options like Conditions just works. The only problem is the max_clone setting.

    Are there any chances that the Required setting will be added to the UI? The only reason I use the code is the lack of this option in the Relationship field interface.

    Thank you for the reply.

    #45062
    PeterPeter
    Moderator

    Hello,

    Please try to reproduce the issue on your staging site and share the credentials, I will take a look.

    Regarding the field UI settings, I will inform the development team to consider supporting that feature in future updates.

    #45084
    Olivier van HeldenOlivier van Helden
    Participant

    I had the same issue. Max clone is enforced with metabox builder, but not with the code generated by metabox builder. However, I found a fix: 1 must be passed as a numeric value, not a string.

    So I replaced
    `
    'field' => [
    'max_clone' => '1',
    ],
    `

    by
    `
    'field' => [
    'max_clone' => 1,
    ],
    `

    And it works as expected now.

    #45100
    EugeneEugene
    Participant

    must be passed as a numeric value, not a string.

    It works, thanks man!

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