Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. <?php
  2. add_action("gform_pre_render", "set_chosen_options");
  3. function set_chosen_options($form){
  4. ?>
  5.  
  6. <script type="text/javascript">
  7. gform.addFilter('gform_chosen_options','set_chosen_options_js');
  8. //limit how many options may be chosen in a multi-select to 2
  9. function set_chosen_options_js(options, element){
  10. //form id = 85, field id = 5
  11. if (element.attr('id') == 'input_85_5'){
  12. options.max_selected_options = 2;
  13. }
  14.  
  15. return options;
  16. }
  17. </script>
  18.  
  19. <?php
  20. //return the form object from the php hook
  21. return $form;
  22. }
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement