2008年10月27日星期一

Re: [fw-mvc] Zend_Form: multiple validator prefix paths

Matthew Weier O'Phinney-3 wrote:
>
>
> <elementPrefixPath>
> <validate>
> <WETB_Validate>WETB/Validate/</WETB_Validate>
> <UKTicket_Validate>UKTicket/Validate/</UKTicket_Validate>
> </validate>
> </elementPrefixPath>
>
> In otherwords, top-level key is the plugin type ('validate'), next level
> key is the prefix, and contents of that key is the path.
>

I have a couple of questions. I'm using an INI file. Is there a "short"
way of doing it there as well?

I have...
----
prefixPath.decorator.prefix = "My_Form_Decorator"
prefixPath.decorator.path = "My/Form/Decorator/"
prefixPath.decorator.type = "decorator"

which works, and then I tried this short form...
----
prefixPath.decorator.My_Form_Decorator = "My/Form/Decorator/"

Which didn't seem to work. Can this be done with Decorators too?

Second question/problem.

I have a validator directory "/My/Validator/" which contains validator
classes. I then created a custom validator called "ProjectExpenses" and
placed in this directory such as...

"/My/Validator/ProjectExpenses.php"

This is similar to how I did my custom decorator, which worked for me. Then,
I use this in my INI file...
prefixPath.validate.My_Validator.prefix = "My_Validator"
prefixPath.validate.My_Validator.path = "My/Validator/"
prefixPath.validate.My_Validator.type = "validate"
[...]
elements.expenses.options.validators.projectexpenses.validator =
"ProjectExpenses"

And I'm getting the error:

"Plugin by name ProjectExpenses was not found in the registry."

I'm guessing whatever I'm doing is not loading my custom validator class
properly. Any suggestions? It would be great if I could condense those 3
lines into a single line, like the above XML config file used, such as...

prefixPath.decorator.My_Form_Decorator = "My/Form/Decorator/"

It'd condense my INI file by a lot, since I'm actually using multiple
sub-forms (each of which uses the same decorator). Speaking of which, is
there a way I can just declare a decorator path in my main form, such that
each sub-form uses it, without having to repeate it for each sub-form?

Cheers!
Fozzy
--
View this message in context: http://www.nabble.com/Zend_Form%3A-multiple-validator-prefix-paths-tp16494104p20193121.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: