PHP Development Framework Yii Framework Tutorial (a) UI component Starrating sample

Source: Internet
Author: User
Tags yii

Cstarrating is mainly used for grading, showing a group of stars (5) for scoring.

The basic usage is as follows

<center class= "Form" >  

<?php $form = $this->beginwidget (' cactiveform ');?> <?php      
           
    $this-> Widget (' cstarrating ', Array (      
        ' model ' => $model,      
        ' attribute ' => ' rating ',      
        ' name ' => ' rating ',      
        ' value ' =>3,      
    )); ?>      
           
    <center class= "row Submit" >      
        <?php echo Chtml::submitbutton (' submit ');?>      
    </center >      
           
<?php $this->endwidget ();?>      
</center><!--form-->

Star values can be accessed through $_post[' rating ' in controller, such as:

Public Function Actionindex ()
{      

    $model =new datamodel ();
    $model->rating=3;
    if (!emptyempty ($_post[' rating ')) 
    { 
        $model->rating=$_post[' rating '];

        if ($model->validate ()) { 
            $this->render (' response ', array (
                ' model ' => $model,

                ));
             return;
        }      

    $this->render (' index ', array ( 
            ' model ' => $model

            );
}

Cstarrating can also be set to read-only, when starrating is used to display the score and the user cannot modify the score. This is accomplished by the ' readOnly ' =>true.

This example downloads: Http://www.imobilebbs.com/download/yii/MaskedTextFieldDemo.zip

See a full set of tutorials: http://www.bianceng.cn/webkf/PHP/201301/35265.htm

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.