diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index 9705d54d4cd2666ff6e1084ef8e81e8a33a56291..924ad0140d720ab181a5ccb62a6c55a18750d8a3 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -926,7 +926,13 @@ class SelectionField extends FormField { 'id'=>1, 'label'=>'Widget', 'required'=>false, 'default'=>false, 'choices'=>array(false=>'Drop Down', true=>'Typeahead'), - 'hint'=>'Typeahead will work better for large lists')), + 'hint'=>'Typeahead will work better for large lists' + )), + 'prompt' => new TextboxField(array( + 'id'=>2, 'label'=>'Prompt', 'required'=>false, 'default'=>'', + 'hint'=>'Leading text shown before a value is selected', + 'configuration'=>array('size'=>40, 'length'=>40), + )), ); } @@ -941,7 +947,7 @@ class SelectionField extends FormField { } class SelectionWidget extends ChoicesWidget { - function render() { + function render($mode=false) { $config = $this->field->getConfiguration(); $value = false; if ($this->value instanceof DynamicListItem) { @@ -953,9 +959,9 @@ class SelectionWidget extends ChoicesWidget { $value = $this->value; $name = $this->getEnteredValue(); } - if (!$config['typeahead']) { + if (!$config['typeahead'] || $mode=='search') { $this->value = $value; - return parent::render(); + return parent::render($mode); } $source = array(); @@ -968,7 +974,8 @@ class SelectionWidget extends ChoicesWidget { <span style="display:inline-block"> <input type="text" size="30" name="<?php echo $this->name; ?>" id="<?php echo $this->name; ?>" value="<?php echo $name; ?>" - autocomplete="off" /> + placeholder="<?php echo $config['prompt']; + ?>" autocomplete="off" /> <input type="hidden" name="<?php echo $this->name; ?>_id" id="<?php echo $this->name; ?>_id" value="<?php echo $value; ?>"/> <script type="text/javascript"> diff --git a/include/class.forms.php b/include/class.forms.php index 07860b9966159f3a5cff38fcf13c915583a41076..ca4cf44a7a38e31eea60365ffc23139e68603275 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -493,6 +493,11 @@ class TextboxField extends FormField { 'id'=>4, 'label'=>'Validation Error', 'default'=>'', 'configuration'=>array('size'=>40, 'length'=>60), 'hint'=>'Message shown to user if the input does not match the validator')), + 'placeholder' => new TextboxField(array( + 'id'=>5, 'label'=>'Placeholder', 'required'=>false, 'default'=>'', + 'hint'=>'Text shown in before any input from the user', + 'configuration'=>array('size'=>40, 'length'=>40), + )), ); } @@ -540,6 +545,11 @@ class TextareaField extends FormField { 'html' => new BooleanField(array( 'id'=>4, 'label'=>'HTML', 'required'=>false, 'default'=>true, 'configuration'=>array('desc'=>'Allow HTML input in this box'))), + 'placeholder' => new TextboxField(array( + 'id'=>5, 'label'=>'Placeholder', 'required'=>false, 'default'=>'', + 'hint'=>'Text shown in before any input from the user', + 'configuration'=>array('size'=>40, 'length'=>40), + )), ); } @@ -660,7 +670,7 @@ class ChoiceField extends FormField { )), 'prompt' => new TextboxField(array( 'id'=>2, 'label'=>'Prompt', 'required'=>false, 'default'=>'', - 'hint'=>'Text shown in the drop-down select before a value is selected', + 'hint'=>'Leading text shown before a value is selected', 'configuration'=>array('size'=>40, 'length'=>40), )), ); @@ -858,7 +868,13 @@ class PriorityField extends ChoiceField { } function getConfigurationOptions() { - return array(); + return array( + 'prompt' => new TextboxField(array( + 'id'=>2, 'label'=>'Prompt', 'required'=>false, 'default'=>'', + 'hint'=>'Leading text shown before a value is selected', + 'configuration'=>array('size'=>40, 'length'=>40), + )), + ); } } FormField::addFieldTypes('Built-in Lists', function() { @@ -907,8 +923,9 @@ class TextboxWidget extends Widget { ?> <span style="display:inline-block"> <input type="text" id="<?php echo $this->name; ?>" - <?php echo $size . " " . $maxlength; ?> - <?php echo $classes.' '.$autocomplete; ?> + <?php echo $size . " " . $maxlength + .' '.$classes.' '.$autocomplete + .' placeholder="'.$config['placeholder'].'"'; ?> name="<?php echo $this->name; ?>" value="<?php echo Format::htmlchars($this->value); ?>"/> </span> @@ -930,7 +947,8 @@ class TextareaWidget extends Widget { $class = 'class="richtext no-bar small"'; ?> <span style="display:inline-block;width:100%"> - <textarea <?php echo $rows." ".$cols." ".$maxlength." ".$class; ?> + <textarea <?php echo $rows." ".$cols." ".$maxlength." ".$class + .' placeholder="'.$config['placeholder'].'"'; ?> name="<?php echo $this->name; ?>"><?php echo Format::htmlchars($this->value); ?></textarea> @@ -967,20 +985,27 @@ class PhoneNumberWidget extends Widget { } class ChoicesWidget extends Widget { - function render() { + function render($mode=false) { $config = $this->field->getConfiguration(); // Determine the value for the default (the one listed if nothing is // selected) $choices = $this->field->getChoices(); - $def_key = $this->field->get('default'); - if (!$def_key && $config['default']) - $def_key = $config['default']; - $have_def = isset($choices[$def_key]); - if (!$have_def) + // We don't consider the 'default' when rendering in 'search' mode + $have_def = false; + if ($mode != 'search') { + $def_key = $this->field->get('default'); + if (!$def_key && $config['default']) + $def_key = $config['default']; + $have_def = isset($choices[$def_key]); + if (!$have_def) + $def_val = ($config['prompt']) + ? $config['prompt'] : 'Select'; + else + $def_val = $choices[$def_key]; + } else { $def_val = ($config['prompt']) - ? $config['prompt'] : 'Select'; - else - $def_val = $choices[$def_key]; + ? $config['prompt'] : 'Select'; + } $value = $this->value; if ($value === null && $have_def) $value = $def_key; diff --git a/include/staff/tickets.inc.php b/include/staff/tickets.inc.php index 6435451b923da826c41c7ea93f7f97893eb09cad..a48f1525651f17f1ead5f58cdca255cba23de13e 100644 --- a/include/staff/tickets.inc.php +++ b/include/staff/tickets.inc.php @@ -617,7 +617,8 @@ if ($results) { elseif (!$f->hasData()) continue; ?><label><?php echo $f->getLabel(); ?>:</label> - <div style="display:inline-block;width: 12.5em;"><?php $f->render(); ?></div> + <div style="display:inline-block;width: 12.5em;"><?php + $f->render('search'); ?></div> <?php } ?> </fieldset> <p>