mint Posted July 30, 2012 Share Posted July 30, 2012 Is there any way to validate a normal chtml text field(Chtml::textField declared without any model class) and display a message on he same page if the user leaves it blank and clicks a submit button. Here is the code <?php echo CHtml::beginForm(array('transaction/disp'),'Post'); ?> <div class="row"> <?php echo CHtml::label('Transaction Status','trst'); ?> </div> <div class="row"> <?php echo CHtml::textField('trst','',array('id'=>'trst','size'=>10)); ?> </div> <?php echo CHtml::submitButton('Submit', array('id'=>'submit','name'=>'submit')); ?> <?php echo CHtml::endForm(); ?> Link to comment Share on other sites More sharing options...
Edward Posted July 30, 2012 Share Posted July 30, 2012 You would have to implement your own cmodel class so you have access to the validators https://github.com/yiisoft/yii/blob/1.1.11/framework/base/CModel.php Link to comment Share on other sites More sharing options...
Recommended Posts