From 7490fbf3095149a0cd8f0ec9909efd821f814585 Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@osticket.com> Date: Thu, 25 Sep 2014 03:58:31 +0000 Subject: [PATCH] Only show multiselect option on dropdown selection Hide multi selection option for typeahead selections --- include/class.dynamic_forms.php | 16 +++++++++++----- include/class.forms.php | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index 8637598c2..b8b040735 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -1064,8 +1064,9 @@ class SelectionField extends FormField { function getConfigurationOptions() { return array( 'widget' => new ChoiceField(array( - 'id'=>1, 'label'=>__('Widget'), 'required'=>false, - 'default' => 'dropdown', + 'id'=>1, + 'label'=>__('Widget'), + 'required'=>false, 'default' => 'dropdown', 'choices'=>array( 'dropdown' => __('Drop Down'), 'typeahead' =>__('Typeahead'), @@ -1076,14 +1077,19 @@ class SelectionField extends FormField { 'hint'=>__('Typeahead will work better for large lists') )), 'multiselect' => new BooleanField(array( - 'id'=>1, 'label'=>__(/* Type of widget allowing multiple selections */ 'Multiselect'), + 'id'=>2, + 'label'=>__(/* Type of widget allowing multiple selections */ 'Multiselect'), 'required'=>false, 'default'=>false, 'configuration'=>array( 'desc'=>__('Allow multiple selections')), - 'hint' => __('Dropdown only'), + 'visibility' => new VisibilityConstraint( + new Q(array('widget__eq'=>'dropdown')), + VisibilityConstraint::HIDDEN + ), )), 'prompt' => new TextboxField(array( - 'id'=>2, 'label'=>__('Prompt'), 'required'=>false, 'default'=>'', + 'id'=>3, + 'label'=>__('Prompt'), 'required'=>false, 'default'=>'', 'hint'=>__('Leading text shown before a value is selected'), 'configuration'=>array('size'=>40, 'length'=>40), )), diff --git a/include/class.forms.php b/include/class.forms.php index 0ebf717d8..8892b2592 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -611,9 +611,9 @@ class FormField { $T = new $clazz(); $config = $this->getConfiguration(); $this->_cform = new Form($T->getConfigurationOptions(), $source); - if (!$source && $config) { + if (!$source) { foreach ($this->_cform->getFields() as $name=>$f) { - if (isset($config[$name])) + if ($config && isset($config[$name])) $f->value = $config[$name]; elseif ($f->get('default')) $f->value = $f->get('default'); -- GitLab