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 8194947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:58:39+00:00 2026-06-07T04:58:39+00:00

I am only trying to create a non-AJAX registration form. When I submit through

  • 0

I am only trying to create a non-AJAX registration form.

When I submit through a CForm, PHP says error() is being called on a non-object. I checked the source file where the error occurred and (using var_dump(get_class($parent->getActiveFormWidget()));) found that getActiveFormWidget() returns a CFormInputElement, which does not have error() defined.

I thought this had to do with CForm::activeForm, but it defaulted to CActiveForm.

I did try 'enableAjaxValidation'=>false.

What am I not understanding? I suspect I misinterpreted something along the way.

CFormInputElement::renderError():

public function renderError()
{
    $parent=$this->getParent();

    // $parent->getActiveFormWidget() returns object that does not define error()

    return $parent->getActiveFormWidget()->error($parent->getModel(), $this->name, $this->errorOptions, $this->enableAjaxValidation, $this->enableClientValidation);
}

Model:

class RegisterFormModel extends CFormModel {

    public $email;
    public $password;
    public $password_confirm;

    public function rules()
    {
        return array(
            array('email, password, password_confirm', 'required'),
            array('password','compare','compareAttribute'=>'password_confirm'),
            array('password, password_confirm','length','min'=>'6','max'=>'20'),
            array('email', 'email'),
            array('email', 'length', 'max'=>256)
        );
    }

    public function attributeLabels()
    {
        return array(
            'email'=>'Email',
            'password'=>'Password',
            'password_confirm'=>'Confirm Password',
        );
    }
}

View:

<div class="form">
<?php echo $form; ?> 
</div><!-- form -->

Controller Action:

class RegisterAction extends CAction
{
    public function run()
    {
        $register_model = new RegisterFormModel;

        $controller = $this->getController();

        $form = new CForm(array(
            'title'=>'Register',
            'enableAjaxValidation'=>false,
            'elements'=>array(
                'email'=>array(
                    'type'=>'text',
                    'maxlength'=>256,
                ),
                'password'=>array(
                    'type'=>'password',
                    'minlength'=>6,
                    'maxlength'=>32,
                ),
                'password_confirm'=>array(
                    'type'=>'password',
                    'minlength'=>6,
                    'maxlength'=>32,
                ),
            ),

            'buttons'=>array(
                'register'=>array(
                    'type'=>'submit',
                    'label'=>'Register',
                ),
            ),
        ), $register_model);

        if($form->submitted('register', true) && $form->validate())
        {
            // ...
        }
        else
        {
            $controller->render('register', array('model'=>$register_model, 'form'=>$form));    
        }
    }    
}
  • 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-07T04:58:40+00:00Added an answer on June 7, 2026 at 4:58 am

    Well, I have never seen using CForm as you show us.

    I recommend you to use the active form widget,

    http://www.yiiframework.com/wiki/195/implementing-a-registration-process-using-the-yii-user-management-module/

    and you need to define all those fields in your CFormModel. This way you will be able to provide proper validation for them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a form using only JavaScript. I mean create a
I am trying to create a simple GUI form which has only 2 elements
I am trying to create a mapper only job via AWS (a streaming job).
I am trying to create a write only file in C on Linux (Ubuntu).
I am trying to create Update trigger which should be invoked only if the
I'm trying to create an HBox in flex that has only the top corners
I'm trying to create a view that only houses reusable HTML blocks that can
I am trying to create a simple Javascript text editor that only makes paragraph
I'm trying to create a jboss-cache for data that is only relevant for a
I was trying to create a CSS only badge with lots of details. The

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.