php - Check value of textbox is blank or not when form submit using yii framework -
i new in yii framework.i doing search search operation using yii framework.my requirement check textbox value null or not in controller.i can print textbox value in variable '$experience'.but cant check blank or not.controler name sitecontroller.php,view search.php , model job.php
my controller sitecontroller.php
<?php class sitecontroller extends controller { public function actionsearch() { $user_id = trim($_get['id']); $model = new job ; if(isset($_post['job'])) { if(yii::app()->getrequest()->getisajaxrequest()) { echo cactiveform::validate(array($jobprofilem2)); yii::app()->end(); } $model->attributes=$_post['job']; if($model->validate()) { $title=$_post['job']['title']; $experience=$_post['job']['experience']; echo "data".$experience=trim($experience); if($_post['job']['experience'] == " ") { echo "hai"; } $model=job::model()->findall(array('select'=>'*',"condition"=>"(title '%$title%') or (key_skills '%$title%')",)); $number=count($model); //$this->redirect($this->createurl('site/search_result',array('title'=>$title,))); } else { yii::app()->user->setflash('error', "validation failed!"); } } $this->render('search',array('model' =>$model)); } } ?>
//view-search.php
<div class="form"> <?php $form=$this->beginwidget('cactiveform', array( 'id'=>'login-form', 'enableclientvalidation'=>false, 'htmloptions' => array(), 'clientoptions'=>array( 'validateonsubmit'=>true ), )); ?> <?php foreach(yii::app()->user->getflashes() $key => $message) { echo '<div class="flash-' . $key . '">' . $message . "</div>\n"; } ?> <div class="row"> <?php echo $form->labelex($model,'keyword'); ?> <?php echo $form->textfield($model,'title'); ?> <?php echo $form->error($model,'keyword'); ?> </div> <div class="row"> <?php echo $form->labelex($model,'experience'); ?> <?php echo $form->textfield($model,'experience'); ?> <?php echo $form->error($model,'experience'); ?> </div> <div class="row buttons"> <?php echo chtml::submitbutton('search'); ?> </div> <?php $this->endwidget(); ?> </div>
i cant print 'hai' message when experince textbox blank.anybody me?
if($_post['job']['experience'] == " ") { echo "hai"; }
this not check whatever string empty. check whatever there space. want check ""
. if not supposed continue follow michiel suggestion.
Comments
Post a Comment