本文整理匯總了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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}