SiteController.php 648 Bytes
Newer Older
Qiang Xue committed
1 2
<?php

Qiang Xue committed
3
use yii\helpers\Html;
Qiang Xue committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

class DefaultController extends \yii\web\Controller
{
	public function actionIndex()
	{
		echo 'hello world';
	}
	
	public function actionForm()
	{
		echo Html::beginForm();
		echo Html::checkboxList('test', array(
			'value 1' => 'item 1',
			'value 2' => 'item 2',
			'value 3' => 'item 3',
		), isset($_POST['test']) ? $_POST['test'] : null, 
		function ($index, $label, $name, $value, $checked) {
			return Html::label(
				$label . ' ' . Html::checkbox($name, $value, $checked),
				null, array('class' => 'inline checkbox')
			);
		});
		echo Html::submitButton();
		echo Html::endForm();
		print_r($_POST);
	}
}