Quote
I already tried to remove the filters() and accessRules(), but my problem still exist. I use the standard CRUD operation, can i bypass the actions?
@mr. Qiang, How about your suggestion?
Quote
I already tried to remove the filters() and accessRules(), but my problem still exist. I use the standard CRUD operation, can i bypass the actions?
@mr. Qiang, How about your suggestion?
Quote
<h2>Register</h2> <?php echo $this->renderPartial('reg', array( 'user'=>$user, 'update'=>false, )); ?>
the reg.php:
<div class="yiiForm"> <p> Fields with <span class="required">*</span> are required. </p> <?php echo CHtml::beginForm(); ?> <?php echo CHtml::errorSummary($user); ?> <div class="simple"> <?php echo CHtml::activeLabelEx($user,'IDROLE'); ?> <?php echo CHtml::activeDropDownList($user,'IDROLE',User::model()->statOpt); ?> </div> <div class="simple"> <?php echo CHtml::activeLabelEx($user,'NAMA'); ?> <?php echo CHtml::activeTextField($user,'NAMA',array('size'=>20,'maxlength'=>20)); ?> </div> <div class="simple"> <?php echo CHtml::activeLabelEx($user,'EMAIL'); ?> <?php echo CHtml::activeTextField($user,'EMAIL',array('size'=>30,'maxlength'=>30)); ?> </div> <div class="simple"> <?php echo CHtml::activeLabelEx($user,'USERNAME'); ?> <?php echo CHtml::activeTextField($user,'USERNAME',array('size'=>15,'maxlength'=>15)); ?> </div> <div class="simple"> <?php echo CHtml::activeLabelEx($user,'PASSWORD'); ?> <?php echo CHtml::activePasswordField($user,'PASSWORD',array('size'=>15,'maxlength'=>15)); ?> </div> <div class="simple"> <?php echo CHtml::activeLabelEx($user,'WEBSITE'); ?> <?php echo CHtml::activeTextField($user,'WEBSITE',array('size'=>50,'maxlength'=>50)); ?> </div> <div class="action"> <?php echo CHtml::submitButton($update ? 'Save' : 'Create'); ?> </div> <?php echo CHtml::endForm(); ?> </div><!-- yiiForm -->
and modify the usercontroller:
public function actionRegister() { $user=new User; if(isset($_POST['User'])) { $user->attributes=$_POST['User']; if($user->save()) $this->redirect(array('success','id'=>$user->IDUSER)); } $this->render('register',array('user'=>$user)); }
But why the error message doesn't appears in the register form?
But in the create form it's work…
somebody fix my code please…
What is your rules() now? Under which situation the error doesn't appear? Does the error appear when you enter nothing in the form?
Quote
I create the registration form, so the unregistered user that access this page.
This is my rules:
public function rules() { return array( array('IDROLE,NAMA,EMAIL,USERNAME,PASSWORD','required'), array('USERNAME','unique', 'message'=>'username is already exist, please change'), array('NAMA','length','max'=>20), array('EMAIL','email'), array('USERNAME','length','max'=>15), array('PASSWORD','length','max'=>15), array('WEBSITE','length','max'=>50), array('IDROLE', 'in', 'range'=>array(1, 2, 3)), ); }
Quote
The error only appear if the user already login.
Quote
No, the error still doesn't appear.
I want to make the error appear when the unregistered user accessing it.
Do you mean even "required" messages do not appear when you submit the form without providing any data?
Quote
Yes, that's correct.
I see no reason why this would happen. Do you have code in your view to display the errors? Did you check if $user->getErrors() is empty or not?
Quote
... <?php echo CHtml::beginForm(); ?> <?php echo CHtml::errorSummary($user); ?> ...
Quote
if i already login into my site, the error code appeared. What should i do?