Skip to content
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

Closed
jymboche opened this issue Jan 24, 2014 · 7 comments
Closed

Phalcon\Mvc\Model\Validator::getOption should be public #1904

jymboche opened this issue Jan 24, 2014 · 7 comments

Comments

@jymboche
Copy link
Contributor

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?

@ghost
Copy link

ghost commented Feb 2, 2014

Done. Could you please test and close the issue if it works for you?

@jymboche
Copy link
Contributor Author

jymboche commented Feb 2, 2014

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?

@ghost
Copy link

ghost commented Feb 2, 2014

Before running ./install please run

php build/gen-build.php

@jymboche
Copy link
Contributor Author

jymboche commented Feb 2, 2014

Ah thanks for the heads up. I just ran gen-build.php. Unfortunately, now I cant load phalcon.so when I restart. I get:

Startup: Unable to load dynamic library '/usr/lib64/php/modules/phalcon.so' - /usr/lib64/php/modules/phalcon.so: undefined symbol: phalcon_get_function_startline in Unknown on line 0

@jymboche
Copy link
Contributor Author

jymboche commented Feb 2, 2014

I also get a warning about an uncasted variable that seems to hang for a while during install. Not sure if its relevant:

/src/cphalcon/build/64bits/phalcon.c:96729:7: warning: assignment makes pointer from integer without a cast [enabled by default]
  file = phalcon_get_class_filename(class_ce);

@ghost
Copy link

ghost commented Feb 3, 2014

I have created a separate PR for that: #1967

@jymboche
Copy link
Contributor Author

jymboche commented Feb 3, 2014

@sjinks I just built from your branch and everything worked as expected. I'll recheck when your PR is merged too. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants