Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Widget для input #57

Closed
zhenya91 opened this issue Jan 11, 2016 · 2 comments
Closed

Widget для input #57

zhenya91 opened this issue Jan 11, 2016 · 2 comments

Comments

@zhenya91
Copy link

Добрый день.
Спасибо за расширение.
Как можно использовать и можно ли вообще использовать widget для одиночного input'a.
Сделал так

<?=$form->field($model,'arrAcc')->widget(MultipleInput::className(),[
        'limit' => 10,
        'columns' =>[
            [
                'type' =>Select2::className(),
                'name' => 'acc',
                'options' => [
                    'pluginOptions' => [
                        'allowClear' => true,
                        'minimumInputLength' => 2,
                        'ajax' => [
                            'url' => \yii\helpers\Url::to(['/ajax-select']),
                            'dataType' => 'json',
                            'data' => new JsExpression('function(params) { return {q:params.term}; }')
                        ],
                        'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
                        'templateResult' => new JsExpression('function(cmp_id) { return cmp_id.text; }'),
                        'templateSelection' => new JsExpression('function (cmp_id) { return cmp_id.text; }'),
                    ],
                ]
            ]
        ]
    ])?>

в итоге в запросе пришел массив следующего вида

[arrAcc] => Array
                (
                    [acc] => Array
                        (
                            [0] => 17
                            [1] => 7
                        )

                )

Можно ли сделать так ,чтобы в запросе при ходил массив следующего вида:

  [arrAcc] => Array
                        (
                            [0] => 17
                            [1] => 7
                        )
@unclead
Copy link
Owner

unclead commented Jan 11, 2016

Попробуйте указать имя колонки arrAcc

<?=$form->field($model,'arrAcc')->widget(MultipleInput::className(),[
        'limit' => 10,
        'columns' =>[
            [
                'type' =>Select2::className(),
                'name' => 'arrAcc',
                'options' => [
                    'pluginOptions' => [
                        'allowClear' => true,
                        'minimumInputLength' => 2,
                        'ajax' => [
                            'url' => \yii\helpers\Url::to(['/ajax-select']),
                            'dataType' => 'json',
                            'data' => new JsExpression('function(params) { return {q:params.term}; }')
                        ],
                        'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
                        'templateResult' => new JsExpression('function(cmp_id) { return cmp_id.text; }'),
                        'templateSelection' => new JsExpression('function (cmp_id) { return cmp_id.text; }'),
                    ],
                ]
            ]
        ]
    ])?>

должно работать, я проверил на тестовом примере с emails - все ок

@unclead unclead closed this as completed Jan 12, 2016
@zhenya91
Copy link
Author

Спасибо. Работает

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants