简体   繁体   English

Yii2 Editable Widget 自定义属性

[英]Yii2 Editable Widget custom attribute

i am working with Yii2 and using Editable Widget我正在使用 Yii2 并使用Editable Widget

My code is below我的代码在下面

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,
                    ],
                ]);

i want to add custom attribute on that generated html tag.我想在生成的 html 标签上添加custom attribute i have tried as below but its throw error我试过如下,但它的抛出错误

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,
                    ],
                ]);

and also i want to add my own class in the generated html i have tried same as above but its not working.而且我想在生成的 html 中添加我自己的类,我已经尝试过与上面相同的方法,但它不起作用。

is there any way to make it possible what i want?有什么方法可以使我想要的成为可能吗?

dosamigos\\editable\\Editable extends yii\\widgets\\InputWidget which has an $options variable that holds: dosamigos\\editable\\Editable扩展了yii\\widgets\\InputWidget ,它有一个$options变量,其中包含:

The HTML attributes for the input tag.输入标签的 HTML 属性。

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,
    ],
]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM