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:
@@ -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]);
|
||||
}
|
||||
|
||||
|
@@ -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>
|
||||
|
Reference in New Issue
Block a user