1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-15 17:44:17 +02:00

feat(form-plugin): add ability to work with string field for select2

This commit is contained in:
Awilum
2020-02-29 11:21:16 +03:00
parent f5ee48655a
commit 264e25589d
2 changed files with 5 additions and 2 deletions

View File

@@ -535,6 +535,8 @@ class FormController extends Controller
$name = isset($properties['name']) ? $properties['name'] : $field_name;
$current_value = isset($properties['value']) ? $properties['value'] : $field_value;
$current_value = array_map('trim', explode(',', $current_value));
return $this->flextype['view']->fetch('plugins/form/templates/fields/tags/field.html', ['title' => $title, 'size' => $size, 'name' => $name, 'id' => $id, 'class' => $class, 'help' => $help , 'options' => $options, 'current_value' => $current_value]);
}

View File

@@ -1,11 +1,12 @@
<div class="form-group {{ size }}">
<label for="{{ id }}" class="form-control-title">{{ tr(title) }}</label>
<select class="{{ class }} js-tags" name="{{ name }}[]" multiple="multiple">
<select class="{{ class }} js-tags" data-name="{{ name }}" multiple="multiple">
{% for key, value in current_value %}
<option value="{{ value }}" selected="selected">{{ value }}</option>
{% endfor %}
</select>
<input type="hidden" name="{{ name }}" value="{{ current_value|join(',') }}">
{% if help %}
<small>{{ help }}</small>
{% endif %}
</div>
</div>