-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Phalcon\Mvc\Model\Validator::getOption should be public #1904
Comments
Done. Could you please test and close the issue if it works for you? |
I just did git checkout 1.3.0 and ./install from build. Phalcon\Version::get() says 1.3.0 BETA 1. But trying $validator->getOption('field') still says: Fatal error: Call to protected method Phalcon\Mvc\Model\Validator::getOption() from context 'App\Models\User' I'm on the correct branch right? |
Before running php build/gen-build.php |
Ah thanks for the heads up. I just ran gen-build.php. Unfortunately, now I cant load phalcon.so when I restart. I get:
|
I also get a warning about an uncasted variable that seems to hang for a while during install. Not sure if its relevant:
|
I have created a separate PR for that: #1967 |
@sjinks I just built from your branch and everything worked as expected. I'll recheck when your PR is merged too. Thanks! |
I believe the methods getOption and getOptions should be public methods...
For instance, overriding Model validations set in Model::validation() is practically impossible. I created a base model class with a method called skipValidation($field) which stores field names in an array. I then created an override for Model::validate by first checking if the field exists in the array. If not I return parent::validate($validator).
However, getting the field name by $validator->getOption('field') doesn't work because the method is protected.
Why do I want to skip a validation? Generally I like to put all validators in the model. In my user model I have password validations. However, when editing the user, if the password is not modified, I dont wish to update (and subsequently) validate the password field.
Thoughts?
The text was updated successfully, but these errors were encountered: