Skip to content

Commit

Permalink
fix(#141): Added defineRules to CalendarModel so users can define the…
Browse files Browse the repository at this point in the history
…ir validation rulesets
  • Loading branch information
seandelaney committed Jun 23, 2022
1 parent 9d70766 commit c3802fa
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions packages/plugin/src/Models/CalendarModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,29 @@ public function jsonSerialize(): array

public function rules(): array
{
return [
[['titleFormat'], 'required', 'when' => function (self $model) {
return $this->defineRules();
}

public function defineRules(): array
{
$rules = parent::defineRules();

$rules[] = [
['titleFormat'],
'required',
'when' => function (self $model) {
return !$model->hasTitleField;
}],
[['titleLabel'], 'required', 'when' => function (self $model) {
}
];

$rules[] = [
['titleLabel'],
'required',
'when' => function (self $model) {
return $model->hasTitleField;
}],
}
];

return $rules;
}
}

0 comments on commit c3802fa

Please sign in to comment.