如何使 Textarea 在 Zend Form 中不可调整大小

How to make Textarea not resizable in Zend Form

我有一个 Zend 表单,其中一个字段是文本区域。我已经使用 'rows' 和 'cols' 设置了它的默认大小,但我希望用户无法更改它。

我试过添加 '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',
        ],
    ]);
}

你可以选择

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

或使用 css class

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

并在您的 css 文件中定义此 css class。