本文整理匯總了PHP中kartik\helpers\Html::radio方法的典型用法代碼示例。如果您正苦於以下問題:PHP Html::radio方法的具體用法?PHP Html::radio怎麽用?PHP Html::radio使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類kartik\helpers\Html
的用法示例。
在下文中一共展示了Html::radio方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: function
<?php
use yii\widgets\Pjax;
use kartik\helpers\Html;
use yii\helpers\ArrayHelper;
Pjax::begin(['id' => 'answer-poll', 'timeout' => 5000]);
if (empty($answerPoll)) {
if (isset($alertMessage) && $alertMessage != '') {
echo $alertMessage;
}
echo Html::beginForm(['/'], 'post', ['data-pjax' => '1', 'class' => '']);
echo Html::radioList('answer_id', $answersData[0]->id, ArrayHelper::map($answersData, 'id', 'answer'), ['item' => function ($index, $label, $name, $checked, $value) {
return Html::tag('div', Html::radio($name, $checked, ['value' => $value, 'label' => Html::encode($label)]), ['class' => 'radio']);
}]);
echo Html::input('hidden', 'question_id', $questions['id']);
echo Html::submitButton('Голосовать', ['class' => 'btn btn-sm btn-primary', 'name' => 'hash-button']);
echo Html::endForm();
} else {
$sumOfVoices = 0;
foreach ($answersData as $item) {
$sumOfVoices = $sumOfVoices + $item->how_many;
}
for ($i = 0; $i < count($answersData); $i++) {
$voicesPer = 0;
if ($sumOfVoices == 0) {
$voicesPer = 0;
} else {
$voicesPer = round($answersData[$i]->how_many / $sumOfVoices, 4) * 100;
}
?>
<div class="poll-option-block">