getActiveFormWidget() returns wrong type?

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 found that getActiveFormWidget() returns a CFormInputElement, which does not have error() defined. I found this out by cramming in:


var_dump(get_class($parent->getActiveFormWidget()));

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

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));    

        }

    }    

}