ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Limiting the number of Relationships chosen in a channel form

January 29, 2014 4:36pm

Subscribe [2]
  • #1 / Jan 29, 2014 4:36pm

    biblio

    9 posts

    Hey there,

    I have a channel form that updates a related field, and everything is working nicely, but I’d like the channel form user to be limited to only 3 relationships.  (there are 100’s of choices, but I only want a max of 3 chosen)  Is this possible?

    I’m using the

    {field:my_custom_field}

    syntax to get the javascript tool for adding/deleting relationships.

    Thanks for any assistance you can give,

    M.

  • #2 / Jan 29, 2014 5:51pm

    Boyink!

    5011 posts

    No way with the built-in relationships field, but I seem to recall Playa offering that ability.

  • #3 / Jan 30, 2014 9:53am

    biblio

    9 posts

    I’ve made a cheesy bit of jquery will keep the casual user from choosing more than three:

    $(".custom_field").click(function() {  
     var bol = $(".custom_field .selected").length >= 3;
     if (bol){
      $(".custom_field").not(".selected").fadeOut();
     }
     else {
      $(".custom_field").not(".selected").fadeIn();
     }
    });

    It would be nice to have this feature in a future version of EE.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases