Answer the question
In order to leave comments, you need to log in
How to update a value in a database?
The database has a table with id and name fields.
On the page, I add new values to the database through a form that sends the values \u200b\u200bto the model, and then to the database.
Here is the form:
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($addform, 'nameEx')->textInput()->label('Exercise name')?>
<div class="form-group">
<?= Html::submitButton('Отправить', ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
<?php $form = ActiveForm::begin(); ?>
<?php foreach ($allNameEx as $item){ ?>
<?= $form->field($addform, 'nameEx')->textInput(array('value'=>$item['name']))->label('');?>
<a href="<?php echo Url::toRoute(['site/ex-delete', 'id' => $item['id']]) ?>" >Удалить</a>
<?php } ?>
<div class="form-group">
<?= Html::submitButton('Отправить', ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question