簡體   English   中英

Yii2 Editable Widget 自定義屬性

[英]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 中添加我自己的類,我已經嘗試過與上面相同的方法,但它不起作用。

有什么方法可以使我想要的成為可能嗎?

dosamigos\\editable\\Editable擴展了yii\\widgets\\InputWidget ,它有一個$options變量,其中包含:

輸入標簽的 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