Skip to content
Snippets Groups Projects
Commit d7a9e2ad authored by Peter Rotich's avatar Peter Rotich
Browse files

Merge pull request #547 from greezybacon/issue/search-no-priority


forms: Allow searching any priority

Reviewed-By: default avatarPeter Rotich <peter@osticket.com>
parents 87f46df2 27921f29
Branches
No related tags found
No related merge requests found
......@@ -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">
......
......@@ -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;
......
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment