Set max items on relationship based on taxonomy?

Support MB Relationships Set max items on relationship based on taxonomy?

  • This topic has 3 replies, 2 voices, and was last updated 1 year ago by PeterPeter.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #45071
    Keith CrossKeith Cross
    Participant

    I have a relationship between two CPTs. CPT-A has two terms in a taxonomy, let's call those "one" and "many" and there would only be one or the other. If CPT-1 has term "one", I want to set the max items of CPT-B to "1" and if the term is "many" I want to set the max items of CPT-B to unlimited (blank). How would I do this? There do not appear to be conditions or toggles for relationship fields.

    #45088
    PeterPeter
    Moderator

    Hello Keith,

    MB Relationships doesn't support an option to set the max connection based on the taxonomy. I think it is possible but you need to create a custom code to do that. However, it is beyond our scope of support. You can contact an expert developer to help you in this case.

    #45091
    Keith CrossKeith Cross
    Participant

    Thank you for the info, Peter! If the taxonomy wasn't a part of this equation...is there *another* way to ensure that when choosing associated CPT-Bs (from CPT-A), that the user is able only choose one, and conversely, be able to choose unlimited CPT-As (from CPT-B)? If there is a video tutorial on how this sort of thing works, please share a link...still learning...

    #45129
    PeterPeter
    Moderator

    In the builder, you can use the setting Max items in the field settings tab, screenshot https://imgur.com/isiuiHQ

    If you use the code, it is the setting max_clone. Please follow the documentation
    https://docs.metabox.io/extensions/mb-relationships/#using-code

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