Answer the question
In order to leave comments, you need to log in
Saving prices for a certain category?
Hi all.
It is not possible to save the price for a certain category ..... the user selects his specialty, saves it, then transfers him to another tab for setting the price, or if the user decides to change the price (PRICE SHOULD BE DISPLAYED IN INPUT), then he changes the value ... like everything, I CAN'T UNDERSTAND HOW TO IMPLEMENT CORRECTLY!
DB:
controller:
public function actionProfile()
{
....
$price = ($price = ProfileHasCategory::findAll(['user_id' => $user_id])) ? $price : new ProfileHasCategory();
return $this->render('profile', [
.......................
'price' => $price,
]);
....
}
<?php foreach ($price as $k) : ?>
<?php $form = ActiveForm::begin() ?>
<tr>
<td>1</td>
<td><?= $k->category_id ?></td>
<td>
<div class="col-md-2">
<?= $form->field($k, 'price')->textInput()->label('') ?>
</div>
</td>
<td><?= Html::submitButton('<span class="glyphicon glyphicon-ok"></span>', ['class' => 'btn btn-success']) ?></td>
</tr>
<?php $form = ActiveForm::end() ?>
<?php endforeach; ?>
Answer the question
In order to leave comments, you need to log in
Good morning.
Why translate to another page in order to indicate the price? All this can be done on one and in one form.
Show the model, validation rules for the price.
What do you want to achieve with this?
$price = ($price = ProfileHasCategory::findAll(['user_id' => $user_id])) ? $price : new ProfileHasCategory();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question