Answer the question
In order to leave comments, you need to log in
Passing data from radio type button via form submission in yii2?
view:
<?php if( !empty($hits) ): ?>
<?php foreach($hits as $hit): ?>
<?=$name2=$hit->naim ?>
<p><input type="radio" name="name1" value="Раз в неделю"><?=$hit->perot ?> </p>
<p><input type="radio" name="name1" value="Раз в месяц "><?=$hit->wtorot ?> </p>
<p><input type="radio" name="name1" value="По праздникам "><?=$hit->tretot ?> </p>
<li><a href="<?= \yii\helpers\Url::to(['site/dob', 'name2' => $name2,'name1' => $name1])?>" "><i class="fa fa-plus-square"></i>Ответить</a></li>
<?php endforeach;?>
<?php endif; ?>
public function actionDob($name2,$name1){
$name2 = Yii::$app->request->get('name2');
$name1 = Yii::$app->request->get('name1');
$posts = Yii::$app->db->createCommand("INSERT INTO golosow(naim,otw) values('{$name2}','{$name1}')")
->execute();
return $this->render('dob');
}
An Error occurred while handling another error:
yii\base\InvalidRouteException: Unable to resolve the request: site/error in W:\domains\localhost\test3\vendor\yiisoft\yii2\base\Controller.php:128
Stack trace:
#0 W:\domains\localhost\test3\vendor\yiisoft\yii2\base\Module.php(528): yii\base\Controller->runAction('error', Array)
#1 W:\domains\localhost\test3\vendor\yiisoft\yii2\web\ErrorHandler.php(108): yii\base\Module->runAction('site/error')
#2 W:\domains\localhost\test3\vendor\yiisoft\yii2\base\ErrorHandler.php(111): yii\web\ErrorHandler->renderException(Object(yii\web\BadRequestHttpException))
#3 [internal function]: yii\base\ErrorHandler->handleException(Object(yii\web\BadRequestHttpException))
#4 {main}
Previous exception:
yii\web\BadRequestHttpException: Отсутствуют обязательные параметры: name1 in W:\domains\localhost\test3\vendor\yiisoft\yii2\web\Controller.php:149
Stack trace:
#0 W:\domains\localhost\test3\vendor\yiisoft\yii2\base\InlineAction.php(51): yii\web\Controller->bindActionParams(Object(yii\base\InlineAction), Array)
#1 W:\domains\localhost\test3\vendor\yiisoft\yii2\base\Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#2 W:\domains\localhost\test3\vendor\yiisoft\yii2\base\Module.php(528): yii\base\Controller->runAction('dob', Array)
#3 W:\domains\localhost\test3\vendor\yiisoft\yii2\web\Application.php(103): yii\base\Module->runAction('site/dob', Array)
#4 W:\domains\localhost\test3\vendor\yiisoft\yii2\base\Application.php(386): yii\web\Application->handleRequest(Object(yii\web\Request))
#5 W:\domains\localhost\test3\frontend\web\index.php(18): yii\base\Application->run()
#6 {main}
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