Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Form Model
- <?php
- /**
- * LoginForm class.
- * LoginForm is the data structure for keeping
- * user login form data. It is used by the 'login' action of 'SiteController'.
- */
- class SearchForm extends CFormModel
- {
- public $date;
- /**
- * Declares the validation rules.
- * The rules state that username and password are required,
- * and password needs to be authenticated.
- */
- public function rules()
- {
- return array(
- array('date', 'required'),
- );
- }
- }
- Controller
- <?php
- class DefaultController extends Controller
- {
- public function actionIndex()
- {
- Yii::import('application.models.rway.*');
- $model = new SearchForm();
- if(isset($_GET['submit'])) {
- var_dump($model->validate());
- if($model->validate()) {
- }
- }
- $this->render('index', array('model'=>$model));
- }
- public function filters() {
- return array(
- 'accessControl'
- );
- }
- public function accessRules() {
- return array(
- array('deny',
- 'actions'=>array('index'),
- 'users'=>array('?'),
- ),
- );
- }
- }
- View
- <?php
- /* @var $this DefaultController */
- $this->breadcrumbs=array(
- $this->module->id,
- );
- ?>
- <div class="form">
- <?php echo CHtml::beginForm($this->createUrl('/rway/default'), 'get'); ?>
- <?php echo CHtml::errorSummary($model); ?>
- <div class="row">
- <?php echo CHtml::activeLabel($model, 'date'); ?>
- <?php echo CHtml::activeTextField($model, 'date'); ?>
- </div>
- <div class="row submit">
- <?php echo CHtml::submitButton('Search', array('name'=>'submit')); ?>
- </div>
- <?php echo CHtml::endForm(); ?>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement