Yii MVC user registration and User Logon (2)

Source: Internet
Author: User



2. log on and register in the view and use the yii small object in the form for analysis.

                        <?php $form = $this -> beginWidget('CActiveForm',                                    array(                                            'enableClientValidation'=>true,                                            'clientOptions'=>array(                                                    'validateOnSubmit'=>true,                                            ),                                    )                                );                         ?>                        <?php $this->endWidget(); ?>

$ This is what? Controller? Small object? Or?

In this way, we can conclude that:


What is the form object created?

The result is as follows:




What is the second parameter when generating a small object $ form object?

This is mainly because Ajax verification is automatically performed when a user is registered, and the yii framework will automatically load the jquery file, but jquery will not verify all fields entered, some fields also need to be verified when the form is submitted.

Do not note the parameters. You can obtain them by automatically generating a file and pasting them. See. If you do not want to asynchronously verify the form, there is no need for the second parameter.






The system automatically generates an automatic logon model upon logon.


There are also automatic verification Components



Common tag settings:

   <?php echo $form->labelEx($user_model, 'username'); ?> <?php echo $form->textField($user_model,'username',array('class'=>'inputBg','id'=>'User_username')); ?><?php echo $form ->error($user_model,'username'); ?> <?php echo $form->passwordField($user_model,'password',array('class'=>'inputBg','id'=>'User_password')); ?><?php echo $form->label($user_model,'password2') ?>  <?php echo $form->radioButtonList($user_model,'user_sex',$sex,array('separator'=>' ')); ?><?php echo $form -> dropDownList($user_model,'user_xueli',$xueli); ?> <?php echo $form -> checkBoxList($user_model,'user_hobby',$hobby,array('separator'=>' ')); ?><?php echo $form -> textArea($user_model,'user_introduce',array('cols'=>50,'rows'=>5)); ?>

The first parameter is a model object, and the second parameter is generally a database field. If you re-confirm the password, you need to set it in the model. The third parameter is generally an array, set Properties

Some are not, such as single-choice buttons, drop-down lists, and check boxes.

Are there other labels? Where? What should I do?


Style:





Yii MVC user registration and User Logon (2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.