Yii remove required fields Asterisk _php tutorial

Source: Internet
Author: User
Tags yii
How do I remove the required Xiangride asterisk? First analyze the code implementation: Public Function Labelex ($model, $attribute, $htmlOptions =array ()) {return Chtml::activelabelex ($model, $ attribute, $htmlOptions);} public static function Activelabelex ($model, $attribute, $htmlOptions =array ()) {$realAttribute = $attribute; ResolveName ($model, $attribute); Strip off square brackets if any$htmloptions[' required ']= $model->isattributerequired ($attribute); return self:: Activelabel ($model, $realAttribute, $htmlOptions);} When a property is required, it renders additional CSS class tags. In particular, it calls cmodel::isattributerequired to determine if a property is required. If it is, it adds a CSS class chtml::requiredcss (public static $REQUIREDCSS = ' required ';) to the label, with Chtml::beforerequiredlabel (public static $beforeRequiredLabel = ";) and Chtml::afterrequiredlabel (public static $afterRequiredLabel = ' * ';) to decorate the label. Public Function isattributerequired ($attribute) Www.2cto.com{foreach ($this->getvalidators ($attribute) as $ Validator) {if ($validator instanceof Crequiredvalidator) return true;} return false;} So remove the asterisk or replace it with another view to redefine Chtml::requiredcss, Chtml::beforerequirEdlabel, Chtml::afterrequiredlabel can not display asterisks. Labelex ($model, ' email ');?>

http://www.bkjia.com/PHPjc/477799.html www.bkjia.com true http://www.bkjia.com/PHPjc/477799.html techarticle How do I remove the required Xiangride asterisk? First analyze the code implementation: Public Function Labelex ($model, $attribute, $htmlOptions =array ()) {return Chtml::activelabelex ($model, $ attribute,$ ...

  • Related Article

    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.