diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index 8637598c23f3b05d3be1450a337a036ed9b1a772..b8b0407356abab13001ba16987a13660b512e403 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 0ebf717d835c6f211a230fcc4530e2be5aeac6ba..8892b2592239e4a8b49fe8df88321bbc1716deec 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');