Relationship field ignores "max_clone" setting
Support › MB Relationships › Relationship field ignores "max_clone" settingResolved
- This topic has 6 replies, 3 voices, and was last updated 1 year ago by
Eugene.
-
AuthorPosts
-
March 28, 2024 at 1:16 PM #45042
Eugene
ParticipantHi,
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, ], ], ] ); }
March 28, 2024 at 1:20 PM #45043Eugene
ParticipantSorry, 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?)
March 28, 2024 at 10:25 PM #45052Peter
ModeratorHello Eugene,
It works well on my site. You can see the max_clone works when editing/creating a
poster
post, notticket
post.March 29, 2024 at 1:10 AM #45057Eugene
ParticipantStrange, 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.
March 30, 2024 at 10:01 AM #45062Peter
ModeratorHello,
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.
April 1, 2024 at 12:56 AM #45084Olivier van Helden
ParticipantI 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.
April 2, 2024 at 4:01 AM #45100Eugene
Participantmust be passed as a numeric value, not a string.
It works, thanks man!
-
AuthorPosts
- You must be logged in to reply to this topic.