Advertisement
longnguyenwp

Conditional logic

Jun 15th, 2020
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.70 KB | None | 0 0
  1. <?php
  2. $fields = [
  3.     [
  4.         'id' => 'template',
  5.         'name' => 'Template',
  6.         'type' => 'select',
  7.         'options' => [
  8.             'home' => 'Home',
  9.             'button' => 'Button',
  10.         ],
  11.         'attributes' => [ 'required' => 'required' ],
  12.     ],
  13.     [
  14.         'id' => 'button_template',
  15.         'type' => 'group',
  16.         'visible' => ['template', '=', 'button'],
  17.         'fields' => [
  18.             [
  19.                 'id' => 'label',
  20.                 'type' => 'text',
  21.                 'name' => 'Label',
  22.                 'size' => 300,
  23.                 'columns' => 12,
  24.             ],
  25.             [
  26.                 'id' => 'button_link_type',
  27.                 'type' => 'select',
  28.                 'name' => 'Link type',
  29.                 'options' => [
  30.                     'none' => 'None',
  31.                     'internal' => 'Internal',
  32.                     'external' => 'External',
  33.                 ],
  34.                 'columns' => 6,
  35.             ],
  36.             [
  37.                 'id' => 'button_link_target',
  38.                 'type' => 'select',
  39.                 'name' => 'Target',
  40.                 'options' => [
  41.                     '_self' => 'Default',
  42.                     '_blank' => 'Blank',
  43.                 ],
  44.                 'columns' => 6,
  45.             ],
  46.             [
  47.                 'id' => 'button_external_link',
  48.                 'type' => 'text',
  49.                 'name' => 'External link',
  50.                 'size' => 300,
  51.                 'hidden' => ['button_link_type', '!=', 'external']
  52.             ],
  53.             [
  54.                 'id' => 'button_internal_link',
  55.                 'type' => 'post',
  56.                 'name' => 'Internal link',
  57.                 'post_type' => ['page', 'post'],
  58.                 'hidden' => ['button_link_type', '!=', 'internal']
  59.             ]
  60.         ]
  61.     ],
  62.     [
  63.         'id' => 'home_template',
  64.         'type' => 'group',
  65.         'visible' => ['template', '=', 'home'],
  66.         'fields' => [
  67.             [
  68.                 'id' => 'visual_buttons',
  69.                 'type' => 'group',
  70.                 'clone' => true,
  71.                 'fields' => [
  72.                     [
  73.                         'id' => 'title',
  74.                         'name' => 'Title',
  75.                         'type' => 'text',
  76.                         'size' => 300,
  77.                         'columns' => 12,
  78.                     ],
  79.                     [
  80.                         'id' => 'description',
  81.                         'name' => 'Description',
  82.                         'type' => 'textarea',
  83.                         'rows' => 3,
  84.                         'columns' => 12,
  85.                     ],
  86.                     [
  87.                         'id' => 'find_out_more',
  88.                         'name' => 'Find out more',
  89.                         'type' => 'text',
  90.                         'size' => 300,
  91.                         'columns' => 6,
  92.                     ],
  93.                     [
  94.                         'id' => 'image',
  95.                         'name' => 'Image',
  96.                         'type' => 'single_image',
  97.                         'columns' => 6,
  98.                     ],
  99.                     [
  100.                         'id' => 'visual_button_link_type',
  101.                         'type' => 'select',
  102.                         'name' => 'Link type',
  103.                         'options' => [
  104.                             'none' => 'None',
  105.                             'internal' => 'Internal',
  106.                             'external' => 'External',
  107.                         ],
  108.                         'columns' => 6,
  109.                     ],
  110.                     [
  111.                         'id' => 'visual_button_link_target',
  112.                         'type' => 'select',
  113.                         'name' => 'Target',
  114.                         'options' => [
  115.                             '_self' => 'Default',
  116.                             '_blank' => 'Blank',
  117.                         ],
  118.                         'columns' => 6,
  119.                     ],
  120.                     [
  121.                         'id' => 'visual_button_external_link',
  122.                         'type' => 'text',
  123.                         'name' => 'External link',
  124.                         'size' => 300,
  125.                         'visible' => ['visual_button_link_type', '=', 'external']
  126.                     ],
  127.                     [
  128.                         'id' => 'visual_button_internal_link',
  129.                         'type' => 'post',
  130.                         'name' => 'Internal link',
  131.                         'post_type' => ['page', 'post'],
  132.                         'visible' => ['visual_button_link_type', '=', 'internal']
  133.                     ]
  134.                 ],
  135.             ]
  136.         ]
  137.     ],
  138.    
  139. ];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement