當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。