From ea249721f6bbc82a57b5cb691914c8adf03588b4 Mon Sep 17 00:00:00 2001 From: Awilum Date: Mon, 10 Feb 2020 14:23:44 +0300 Subject: [PATCH] feat(form-plugin): add tags field #360 --- .../form/app/Controllers/FormController.php | 22 ++++++++----------- .../form/templates/fields/tags/field.html | 11 ++++++++++ 2 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 site/plugins/form/templates/fields/tags/field.html diff --git a/site/plugins/form/app/Controllers/FormController.php b/site/plugins/form/app/Controllers/FormController.php index ecc2f8d1..f245f87c 100644 --- a/site/plugins/form/app/Controllers/FormController.php +++ b/site/plugins/form/app/Controllers/FormController.php @@ -533,21 +533,17 @@ class FormController extends Controller */ protected function tagsField(string $field_id, string $field_name, $field_value, array $properties) : string { - $title = isset($properties['title']) ? $properties['title'] : ''; - $size = isset($properties['size']) ? $this->sizes[$properties['size']] : $this->sizes['12']; - $help = isset($properties['help']) ? $properties['help'] : ''; + $title = isset($properties['title']) ? $properties['title'] : ''; + $size = isset($properties['size']) ? $this->sizes[$properties['size']] : $this->sizes['12']; + $help = isset($properties['help']) ? $properties['help'] : ''; + $options = isset($properties['options']) ? $properties['options'] : []; + $id = isset($properties['id']) ? $properties['id'] : $field_id; + $class = isset($properties['class']) ? $properties['class'] . $this->field_class : $this->field_class; + $name = isset($properties['name']) ? $properties['name'] : $field_name; + $current_value = isset($properties['value']) ? $properties['value'] : $field_value; - $attributes = isset($properties['attributes']) ? $properties['attributes'] : []; - $attributes['id'] = isset($attributes['id']) ? $attributes['id'] : $field_id; - $attributes['class'] = isset($attributes['class']) ? $attributes['class'] : $this->field_class; + 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]); - $field = '
'; - $field .= ($title ? Form::label($field_id, __($title)) : ''); - $field .= ''; - $field .= ($help ? '' . __($help) . '' : ''); - $field .= '
'; - - return $field; } /** diff --git a/site/plugins/form/templates/fields/tags/field.html b/site/plugins/form/templates/fields/tags/field.html new file mode 100644 index 00000000..b779a6e9 --- /dev/null +++ b/site/plugins/form/templates/fields/tags/field.html @@ -0,0 +1,11 @@ +
+ + + {% if help %} + {{ help }} + {% endif %} +
\ No newline at end of file