当前位置: 首页>>代码示例>>PHP>>正文


PHP CActiveRecord::isAttributeRequired方法代码示例

本文整理汇总了PHP中CActiveRecord::isAttributeRequired方法的典型用法代码示例。如果您正苦于以下问题:PHP CActiveRecord::isAttributeRequired方法的具体用法?PHP CActiveRecord::isAttributeRequired怎么用?PHP CActiveRecord::isAttributeRequired使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CActiveRecord的用法示例。


在下文中一共展示了CActiveRecord::isAttributeRequired方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isAttributeRequired

 public function isAttributeRequired($attribute)
 {
     if (in_array($attribute, array('_image'))) {
         return true;
     }
     return parent::isAttributeRequired($attribute);
 }
开发者ID:DarkAiR,项目名称:test,代码行数:7,代码来源:News.php

示例2: getElements

 /**
  * @param CActiveRecord $model
  * @param array $attributes
  * @return array
  */
 public static function getElements($model, $attributes = [])
 {
     $modelAttributes = $model->getAttributes();
     $modelElements = [];
     foreach ($modelAttributes as $attrName => $attrVal) {
         if (!empty($attributes)) {
             foreach ($attributes as $attr) {
                 if ($attrName === $attr) {
                     $modelElements[$attr] = ['label' => $model->getAttributeLabel($attr), 'required' => $model->isAttributeRequired($attr), 'type' => 'text'];
                 }
             }
             continue;
         }
         $modelElements[$attrName] = ['label' => $model->getAttributeLabel($attrName), 'required' => $model->isAttributeRequired($attrName), 'type' => 'text'];
         //			if ($field->inputType == 'dropdownlist') {
         //				$elements['elements']['contextFields']['elements'][$field->inputName . '-' . $field->id]['items'] =
         //					Options::model()->getContextFieldOptions($field->id);
         //			}
     }
     return $modelElements;
 }
开发者ID:schrapps,项目名称:risksur,代码行数:26,代码来源:ContextController.php

示例3: checkUserData

 /**
  * Uses HUserInfoForm to check if we have all data, that we need from new user
  * displays the form to get the required, but not specified user data
  * 
  * @param  CActiveRecord $user user model
  * @return CActiveRecord user model with correct data
  */
 protected function checkUserData($user)
 {
     // trying to fill email and username fields
     // NOTE: we display `username` field in our form only if it is required by the model
     if ($this->usernameAttribute && !$user->isAttributeRequired($this->usernameAttribute)) {
         $this->usernameAttribute = false;
     }
     $form = new HUserInfoForm($user, $this->_emailAttribute, $this->usernameAttribute);
     if (!$form->validateUser()) {
         // We need to request some info from user
         $this->controller->render('hoauth.views.form', array('form' => $form));
         Yii::app()->end();
     }
     // updating attributes in $user model (if needed)
     $user = $form->validUserModel;
     return $user;
 }
开发者ID:Dvionst,项目名称:vvfy,代码行数:24,代码来源:HOAuthAction.php

示例4: isAttributeRequired

 public function isAttributeRequired($attribute)
 {
     if (!$this->eavEnable) {
         return parent::isAttributeRequired($attribute);
     }
     if ($this->hasEavAttribute($attribute)) {
         return $this->isEavAttributeRequired($attribute);
     }
     return parent::isAttributeRequired($attribute);
 }
开发者ID:kuzmina-mariya,项目名称:unizaro-spa,代码行数:10,代码来源:EavActiveRecord.php

示例5: isRequired

 /**
  * Checks if a model attribute is required.
  *
  * @param CActiveRecord $model Model attribute belongs to
  * @param string $attribute Name of attribute
  * @return mixed True if required, else false
  */
 public function isRequired($model, $attribute)
 {
     return $model->isAttributeRequired($attribute);
 }
开发者ID:elephanthead,项目名称:itr,代码行数:11,代码来源:BetterCActiveForm.php


注:本文中的CActiveRecord::isAttributeRequired方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。