Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8866495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:47:55+00:00 2026-06-14T16:47:55+00:00

I have an issue about displaying error in a yii form. This is my

  • 0

I have an issue about displaying error in a yii form.

This is my controller:

$custom_user->attributes = $_POST['CustomUser'];
if($custom_user->validate())
{
  ...
  save
  ...
}
else
{
  $custom_user->addError('username', 'Error X');
  $this->redirect(array('access/index'),
                  array('user'=>$custom_user,
                        'tab'=>$tab_person,
  ));
}

This is my index view:

<?php $form=$this->beginWidget('BaseForm', array(
                            'id'=>'user-form',
                           'action'=>Yii::app()->createUrl('person/createUser'))); ?>

 <?php echo $form->errorSummary($user);?>

 <div class="right">
        <?php echo $form->textField($user,'username',array('size'=>30,'maxlength'=>255)); ?>
        <br/><?php echo $form->error($user,'username'); ?>
    </div>
  ...
  ...
 <div style="float: left;">
        <?php echo $form->dateField($user,'valid_from',null,'valid_from_formated'); ?>
        <br/><?php echo $form->error($user,'valid_from'); ?>
 </div>

Here is my BaseForm

public $enableClientValidation = true;
public $enableAjaxValidation = true;
public $clientOptions = array(  'hideErrorMessage'=>false,
                                'validateOnSubmit'=>true,
                                'validateOnChange'=>false,
                                'validateOnType'=>false,
                                'afterValidateAttribute' => 'js:enableSubmitAV',
                                'afterValidate' => 'js:submitFormAV'); // always fires this after

Here is the problem:

“$form->errorSummary($user);” is empty
and noting is display under “$form->error($user,’username’);”

But if I look in Firebug I can see that under “response” tab:

{“CustomUser_valid_until”:[“Valid Until must be
greater than \”20121127\”.”]}

it’s a good thing because it means my rules work great. But none errors are displayed. Not this one and even the error “Error X” I add in my controller is not diplayed… (I’m sure I pass throught the else statement, i tried it).

So, does anyone could have an idea?

Thanks for reading me and sorry for my approximate English.

Have a good day 🙂

Michaël

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T16:47:56+00:00Added an answer on June 14, 2026 at 4:47 pm

    You are redirecting, meaning a whole new request is called, and any responses are deleted.

    Why are you redirecting to “access/index” rather than just calling the view? If you do need to redirect, which you definitely can, try setting a flash variable as it is store in the browser’s session and will persist through redirects:

    Yii::app()->user->setFlash('username', "Error X");
    

    Then on the access/index page:

    <?php if(Yii::app()->user->hasFlash('username')):?>
        <div class="error">
            <?php echo Yii::app()->user->getFlash('username'); ?>
        </div>
    <?php endif; ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Read about the issue in this stackoverflow question . Still have the same issue
I have read a lot about this issue but mine still seems to be
Please help me about this issue... In my application i have calender where user
First let me say that I have been working on this issue for about
I am working on an application an have an issue about running shell command
I have research about an issue and could not find a solution for it
I have a serious issue with Liferay 6.1 themes , I know well about
I have issue with: <form:checkboxes path=roles cssClass=checkbox items=${roleSelections} /> If previous line is used
I have a minor issue with displaying TextViews in my app while running on
I have sort of an odd issue. I have never seen this before and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.