Skip to content

Instantly share code, notes, and snippets.

@khoand0000
Created December 19, 2015 03:22
Show Gist options
  • Save khoand0000/280c2b5bde8d13b694d3 to your computer and use it in GitHub Desktop.
Save khoand0000/280c2b5bde8d13b694d3 to your computer and use it in GitHub Desktop.
update condition is not working with html control ref: https://piklist.com/user-guide/docs/field-parameters/conditions/
piklist('field', array(
'type' => 'select'
,'field' => 'master_field'
,'label' => 'Master field'
,'choices' => array(
'update_field' => 'Update'
,'no_update_field' => 'No update'
)
,'conditions' => array(
array(
'type' => 'update'
,'value' => 'update_field'
,'field' => 'my_field'
,'update' => 'Hello World!'
)
)
));
piklist('field', array(
// 'type' => 'html' // is not working
'type' => 'text'
,'field' => 'my_field'
,'label' => 'Show/Hide Field'
,'description' => 'This field is updated by the Select field above'
));
@sbruner
Copy link

sbruner commented Dec 20, 2015

The documentation was missing the clearing part of the condition. I just updated it. Try this:

piklist('field', array(
    'type' => 'select'
    ,'field' => 'master_field'
    ,'label' => 'Master field'
    ,'choices' => array(
      'update_field' => 'Update'
      ,'no_update_field' => 'No update'
    )
    ,'conditions' => array(
      array(
        'type' => 'update'
        ,'value' => 'update_field'
        ,'field' => 'my_field'
        ,'update' => 'Hello World!'
      )
      ,array(
        'field' => 'my_field'
        ,'value' => 'no_update_field'
        ,'update' => ''
        ,'type' => 'update'
      )
    )
  ));

  piklist('field', array(
    'type' => 'text'
    ,'field' => 'my_field'
    ,'label' => 'Show/Hide Field'
    ,'value' => 'Hello World!' // Set default value
    ,'description' => 'This field is updated by the Select field above'
  ));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment