<button class = "btn btn-cart" type="button" onclick="cart.add(<?= $id?>, document.querySelector('#quantity-<?= $id?>').value);">В корзину</button>
<input id="quantity-<?= $id?>" class="input_quantity" name="quantity" type="text" value="1" size="1"/>
<button class = "btn btn-cart" type="button" onclick="cart.add(<?= $id?>);">В корзину</button>
onclick="cart.add(<?= $id?>, document.querySelector('.input_quantity').value);"
<?php
echo $form->field($model, 'items')->widget(MultipleInput::className(), [
'columns' => [
[
'name' => 'slide',
'type' => \kartik\select2\Select2::className(),
'options' => [
'options' => ['placeholder' => 'Поиск ...'],
// 'initValueText' => empty($model->items) ? '' : Item::findOne($model->items)->title,
'pluginOptions' => [
'allowClear' => true,
'minimumInputLength' => 3,
'language' => 'ru',
'ajax' => [
'url' => \yii\helpers\Url::to(['item-list']),
'dataType' => 'json',
'data' => new JsExpression('function(params) { return {q:params.term}; }')
],
'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
'templateResult' => new JsExpression('function(item_id) { return item_id.text; }'),
'templateSelection' => new JsExpression('function (item_id) { return item_id.text; }'),
],
],
],
]
])->label(false);
?>
*/
public function actionIndex()
{
$model = new Slider();
if ($model->load(Yii::$app->request->post())) {
foreach ($model->items['slide'] as $id){
$model = new Slider();
$model->item_id = $id;
$model->save();
}
Yii::$app->session->setFlash('success', "Слайдер сохранен");
return $this->redirect(['index']);
}
return $this->render('index', [
'model' => $model,
]);
}
public $items;
public function init()
{
parent::init();
$title = [];
foreach ($this->itemall as $item){
$title[]['slide'] = empty($item['item_id']) ? '' : Item::findOne($item['item_id'])->title;
}
$this->items = $title;
}
public function getItemAll()
{
return self::find()->orderBy(['id' => SORT_ASC])->asArray()->all();
}
'initValueText' => empty($model->items) ? '' : Item::findOne($model->items)->title,
public $items;
public function init()
{
parent::init();
$title = [];
foreach ($this->itemall as $item){
$title[]['slide'] = empty($item['item_id']) ? '' : Item::findOne($item['item_id'])->title;
}
$this->items = $title;
}
public function getItemAll()
{
return self::find()->orderBy(['id' => SORT_ASC])->asArray()->all();
}
'initValueText' => empty($model->items) ? '' : Item::findOne($model->items)->title,
[['order_id'], 'exist', 'skipOnError' => true, 'targetClass' => Item::className(), 'targetAttribute' => ['order_id' => 'id']],