Yii2 可编辑小部件自定义属性

Yii2 Editable Widget custom attribute

我正在使用 Yii2 并使用 Editable Widget

我的代码在下面

Editable::widget([
                    'id' => 1,
                    'name' => 'assignTo',
                    'value' => 1,
                    'url' => 'url here',
                    'type' => 'select',
                    'mode' => 'inline',
                    'clientOptions' => [
                        'toggle' => 'dblclick',
                        'emptytext' => 'Unassigned',
                        'placement' => 'right',
                        'select2' => [
                            'width' => '124px'
                        ],
                        'source' => 1,
                        'value' => 1,
                    ],
                ]);

我想在生成的 html 标签上添加 custom attribute。我试过如下但它抛出错误

Editable::widget([
                    'id' => 'assignTo_'.$todo->id,
                    'name' => 'assignTo',
                    'redirect_url' => 'custom_attriute', // this is custom attribute that i need
                    'class' => 'my own custom class', // this is custom attribute that i need
                    'value' => 1,
                    'url' => 'url here',
                    'type' => 'select',
                    'mode' => 'inline',
                    'clientOptions' => [
                        'toggle' => 'dblclick',
                        'emptytext' => 'Unassigned',
                        'placement' => 'right',
                        'select2' => [
                            'width' => '124px'
                        ],
                        'source' => 1,
                        'value' => 1,
                    ],
                ]);

而且我想在生成的 html 中添加我自己的 class 我已经尝试过与上面相同的方法但它不起作用。

有什么方法可以实现我想要的吗?

dosamigos\editable\Editable extends yii\widgets\InputWidget 其中有一个 $options 变量,其中包含:

The HTML attributes for the input tag.

Editable::widget([
    'id' => 'assignTo_'.$todo->id,
    'name' => 'assignTo',
    'options' => [
        'redirect_url' => 'custom_attriute', // this is custom attribute that i need
        'class' => 'my own custom class', // this is custom attribute that i need
    ],
    'value' => 1,
    'url' => 'url here',
    'type' => 'select',
    'mode' => 'inline',
    'clientOptions' => [
        'toggle' => 'dblclick',
        'emptytext' => 'Unassigned',
        'placement' => 'right',
        'select2' => [
            'width' => '124px'
        ],
        'source' => 1,
        'value' => 1,
    ],
]);