Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. Form Model
  2. <?php
  3.  
  4. /**
  5. * LoginForm class.
  6. * LoginForm is the data structure for keeping
  7. * user login form data. It is used by the 'login' action of 'SiteController'.
  8. */
  9. class SearchForm extends CFormModel
  10. {
  11. public $date;
  12.  
  13. /**
  14. * Declares the validation rules.
  15. * The rules state that username and password are required,
  16. * and password needs to be authenticated.
  17. */
  18. public function rules()
  19. {
  20. return array(
  21. array('date', 'required'),
  22. );
  23. }
  24.  
  25. }
  26.  
  27.  
  28.  
  29. Controller
  30. <?php
  31.  
  32. class DefaultController extends Controller
  33. {
  34. public function actionIndex()
  35. {
  36. Yii::import('application.models.rway.*');
  37. $model = new SearchForm();
  38.  
  39. if(isset($_GET['submit'])) {
  40. var_dump($model->validate());
  41. if($model->validate()) {
  42.  
  43. }
  44. }
  45. $this->render('index', array('model'=>$model));
  46. }
  47. public function filters() {
  48. return array(
  49. 'accessControl'
  50. );
  51. }
  52. public function accessRules() {
  53. return array(
  54. array('deny',
  55. 'actions'=>array('index'),
  56. 'users'=>array('?'),
  57. ),
  58. );
  59. }
  60. }
  61.  
  62.  
  63.  
  64. View
  65. <?php
  66. /* @var $this DefaultController */
  67.  
  68. $this->breadcrumbs=array(
  69. $this->module->id,
  70. );
  71. ?>
  72.  
  73. <div class="form">
  74. <?php echo CHtml::beginForm($this->createUrl('/rway/default'), 'get'); ?>
  75.  
  76. <?php echo CHtml::errorSummary($model); ?>
  77.  
  78. <div class="row">
  79. <?php echo CHtml::activeLabel($model, 'date'); ?>
  80. <?php echo CHtml::activeTextField($model, 'date'); ?>
  81. </div>
  82.  
  83. <div class="row submit">
  84. <?php echo CHtml::submitButton('Search', array('name'=>'submit')); ?>
  85. </div>
  86. <?php echo CHtml::endForm(); ?>
  87. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement