Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.03 KB | None | 0 0
  1. // Set your conditions here
  2. // FIELD_KEY:OPTION_VALUE:FIELD_KEY_TO_SHOW
  3. $conditions = [
  4.     'destination:pelion:ekdromi Pelion',
  5.     'destination:crete:ekdromi crete',
  6.     'destination:rhodos:ekdromi rodos',
  7. ];
  8.  
  9. // DO NOT EDIT BELOW
  10. JHtml::script('com_convertforms/conditional_fields.js', ['relative' => true]);
  11. $options = JFactory::getDocument()->getScriptOptions('com_convertforms');
  12. foreach ($conditions as $key => $form_1_condition)
  13. {
  14.     $parts = explode(':', $form_1_condition);
  15.  
  16.     $options['conditional_fields'][1][] = [
  17.         'if' => [
  18.             [
  19.                 'field_name' => $parts[0],
  20.                 'value' => $parts[1]
  21.             ]
  22.         ],
  23.         'then' => [
  24.             [
  25.                 'field_name' => $parts[2],
  26.                 'trigger' => 'show_field'
  27.             ],
  28.             [
  29.                 'field_name' => $parts[2],
  30.                 'trigger' => 'is_required'
  31.             ]
  32.         ],
  33.         'else' => [
  34.             [
  35.                 'field_name' => $parts[2],
  36.                 'trigger' => 'hide_field'
  37.             ],
  38.             [
  39.                 'field_name' => $parts[2],
  40.                 'trigger' => 'is_not_required'
  41.             ]
  42.         ]      
  43.     ];
  44. }
  45.  
  46. JFactory::getDocument()->addScriptOptions('com_convertforms', $options);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement