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

feat(form-plugin): add textarea field #360

This commit is contained in:
Awilum
2020-02-08 14:55:37 +03:00
parent 40c272c0b7
commit 73d1353281
2 changed files with 18 additions and 17 deletions

View File

@@ -477,18 +477,12 @@ class FormController extends Controller
$title = isset($properties['title']) ? $properties['title'] : '';
$size = isset($properties['size']) ? $this->sizes[$properties['size']] : $this->sizes['12'];
$help = isset($properties['help']) ? $properties['help'] : '';
$value = isset($properties['value']) ? $properties['value'] : $field_value;
$id = isset($properties['id']) ? $properties['id'] : $field_id;
$name = isset($properties['name']) ? $properties['name'] : $field_name;
$class = isset($properties['class']) ? $properties['class'] : $this->field_class;
$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;
$field = '<div class="form-group ' . $size . '">';
$field .= ($title ? Form::label($field_id, __($title)) : '');
$field .= Form::textarea($field_name, $field_value, $attributes);
$field .= ($help ? '<small class="form-text text-muted">' . __($help) . '</small>' : '');
$field .= '</div>';
return $field;
return $this->flextype['view']->fetch('plugins/form/templates/fields/textarea/field.html', ['title' => $title, 'size' => $size, 'name' => $name, 'id' => $id, 'class' => $class, 'help' => $help , 'value' => $value]);
}
/**
@@ -537,12 +531,12 @@ class FormController extends Controller
*/
protected function textField(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'] : '';
$id = isset($properties['id']) ? $properties['id'] : $field_id;
$name = isset($properties['name']) ? $properties['name'] : $field_name;
$class = isset($properties['class']) ? $properties['class'] : $this->field_class;
$title = isset($properties['title']) ? $properties['title'] : '';
$size = isset($properties['size']) ? $this->sizes[$properties['size']] : $this->sizes['12'];
$help = isset($properties['help']) ? $properties['help'] : '';
$id = isset($properties['id']) ? $properties['id'] : $field_id;
$name = isset($properties['name']) ? $properties['name'] : $field_name;
$class = isset($properties['class']) ? $properties['class'] : $this->field_class;
$value = isset($properties['value']) ? $properties['value'] : $field_value;
return $this->flextype['view']->fetch('plugins/form/templates/fields/text/field.html', ['title' => $title, 'size' => $size, 'name' => $name, 'id' => $id, 'class' => $class, 'help' => $help, 'value' => $value]);

View File

@@ -0,0 +1,7 @@
<div class="form-group {{ size }}">
<label for="{{ id }}" class="form-control-title">{{ tr(title) }}</label>
<textarea id="{{ id }}" name="{{ name }}" rows="0" cols="0" class="{{ class }}">{{ value }}</textarea>
{% if help %}
<small>{{ help }}</small>
{% endif %}
</div>