Add showSearch option to dropdown

This is a highly specific option, so we shouldn't add it to the FormField class itself
This commit is contained in:
Samuel Georges 2016-03-25 18:21:58 +11:00
parent 5789d0242f
commit 0aef151d9a
2 changed files with 13 additions and 1 deletions

View File

@ -548,6 +548,17 @@ class FormField
return HtmlHelper::nameToId($id);
}
/**
* Returns a raw config item value.
* @param string $value
* @param string $default
* @return mixed
*/
public function getConfig($value, $default = null)
{
return array_get($this->config, $value, $default);
}
/**
* Returns this fields value from a supplied data set, which can be
* an array or a model or another generic collection.

View File

@ -1,5 +1,6 @@
<?php
$fieldOptions = $field->options();
$useSearch = $field->getConfig('showSearch', true);
?>
<!-- Dropdown -->
<?php if ($this->previewMode): ?>
@ -8,7 +9,7 @@
<select
id="<?= $field->getId() ?>"
name="<?= $field->getName() ?>"
class="form-control custom-select"
class="form-control custom-select <?= $useSearch ? '' : 'select-no-search' ?>"
<?= $field->getAttributes() ?>>
<?php if ($field->placeholder): ?>
<option value=""><?= e(trans($field->placeholder)) ?></option>