本文整理汇总了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);
}