New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it easier to add custom validation #196
Conversation
As suggested in the PHPdoc of the Yii `Model::defineRules()` method: > Models should override this method instead of [[rules()]] so [[EVENT_DEFINE_RULES]] handlers can modify the class-defined rules.
I want to make the Event::on(
Submission::class,
Submission::EVENT_DEFINE_RULES,
function(DefineRulesEvent $event) {
$event->rules[] = [['fromName', 'subject'], 'required'];
}
); However, it only works when I change Discord: https://discordapp.com/channels/456442477667418113/456442884258922529/772923383573905470 |
Any status update on this? Changing the method from |
Would really like to see this implemented! |
Discovered with @bencroker that this might be a breaking change, because Edit: Maybe not? Seems like we could quietly support 3.4+, as long as the method signature is compatible. The real fix might be more like adding |
@AugustMiller Wouldn't it be possible to bump the required Craft CMS version to 3.4 in composer.json for the next version? |
Thanks @nstCactus! Just merged and released as 2.3.0. |
Description
As suggested in the PHPdoc of the Yii
Model::defineRules()
method: