如何使Textarea不能以Zend格式调整大小

时间:2019-01-30 14:57:17

标签: textarea zend-form zend-framework3

我有一个Zend Form,它的一个字段是Textarea。我已经使用“行”和“列数”设置了它的默认大小,但是我希望用户不能更改它。

我尝试添加'resize'=> false,但是没有用。

public function __construct()
{
    parent::__construct('form');
    $this->setAttribute('method', 'post');
    $this->setAttribute('role', 'form');

    $this->add([
        'name' => 'feedback',
        'type' => Textarea::class,
        'attributes' => [
            'id' => 'feedback',
            'class' => 'mdc-text-field__input',
            'rows' => 3,
            'cols' => 4,
            'required' => false,
        ],
        'options' => [
            'label' => 'Feedback',
        ],
    ]);
}

1 个答案:

答案 0 :(得分:0)

您可以选择

attributes => [
    ...,
    'style' => 'resize:none'
]

或使用CSS类

attributes => [
    ...,
    'class' => 'notresizable'
]

并在css文件中定义此css类。