本文整理汇总了PHP中BaseModel::rules方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseModel::rules方法的具体用法?PHP BaseModel::rules怎么用?PHP BaseModel::rules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseModel
的用法示例。
在下文中一共展示了BaseModel::rules方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rules
/**
* Returns this model's validation rules.
*
* @return array
*/
public function rules()
{
$rules = parent::rules();
// Use Yii's stricter URL validator here
$rules[] = array('url', 'url');
return $rules;
}
示例2: rules
/**
* Define validation rules
*
* @return array with validation rules
*/
public function rules()
{
// add the custom validator for validating Project Id
$rules = parent::rules();
$rules[] = array('projectId', 'Craft\\Optimizely_ProjectIdValidator');
return $rules;
}
示例3: rules
/**
* @inheritDoc BaseModel::rules()
*
* @return array
*/
public function rules()
{
$rules = parent::rules();
if ($this->urlFormatIsRequired) {
$rules[] = array('urlFormat', 'required');
}
if ($this->nestedUrlFormatIsRequired) {
$rules[] = array('nestedUrlFormat', 'required');
}
return $rules;
}
示例4: rules
/**
* @inheritDoc BaseModel::rules()
*
* @return array
*/
public function rules()
{
$rules = parent::rules();
if ($this->decimals && intval($this->decimals) && intval($this->decimals) > 0) {
foreach ($rules as $key => &$rule) {
if (isset($rule[0]) && isset($rule[1]) && ($rule[0] == 'min' || $rule[0] == 'max') && $rule[1] == 'numerical') {
$rule['integerOnly'] = false;
}
}
}
return $rules;
}
示例5: rules
/**
* @inheritDoc BaseModel::rules()
*
* @return array
*/
public function rules()
{
$rules = parent::rules();
if ($this->expectedPrice == 0) {
// CC info not required
foreach ($rules as &$rule) {
if ($rule[1] == 'required') {
$attributes = explode(',', $rule[0]);
foreach (array('ccTokenId', 'expMonth', 'expYear') as $attribute) {
$pos = array_search($attribute, $attributes);
if ($pos !== false) {
array_splice($attributes, $pos, 1);
}
}
$rule[0] = implode(',', $attributes);
break;
}
}
}
return $rules;
}
示例6: rules
public function rules()
{
$rules = parent::rules();
$rules[] = ['numberOfCrops', 'validateNumberOfCrops'];
return $rules;
}
示例7: rules
public function rules()
{
// maxSize is 3MB
return array_merge(parent::rules(), array(array('attachment', 'file', 'maxSize' => 3145728, 'allowEmpty' => true)));
}