On 14 Feb 2008, at 13:11, Matthew Weier O'Phinney wrote:

-- Greg Frith <[EMAIL PROTECTED]> wrote
(on Thursday, 14 February 2008, 12:24 PM +0000):
I'm trying to use my XML config file to add custom validator paths to every
element in a Zend_Form instance.

Here is an extract from my configuration file (this is the config tree I pass
to new Zend_Form):

<name>userRegister</name>
<action>/authentication/register/</action>
<method>post</method>
<elementPrefixPaths>

The above should be singular (even though it allows for multiple
entries): 'elementPrefixPath'. That should solve your issue, including
the exception from attempting to load the custom validator class.

Thanks Matthew,

Have tried this (see below) but still the extra prefix and path are not added to element pluginloaders.

<name>userRegister</name>
<action>/authentication/register/</action>
<method>post</method>
<elementPrefixPath>
        <validate>
                <prefix>WETB_Validate</prefix>
                <path>WETB/Validate</path>
                <type>validate</type>
        </validate>
</elementPrefixPath>
<elements>
        <firstname>
                <type>text</type>
                <options>
                <label>Surname:</label>
                <validators>
<!--         <wordchars>
                                <validator>WordChars</validator>
                                        <options>
                                                
<allowWhieSpace>1</allowWhieSpace>
                                        </options>
                                </wordchars>-->
                                <stringlength>
                                        <validator>StringLength</validator>
                                        <options>
                                                <min>1</min>
                                                <max>20</max>
                                        </options>
                                </stringlength>
                        </validators>
                </options>
        </firstname>
.....

function registerAction() {
        $form = new Zend_Form($this->config->forms->userRegistration);
        
        $fn = $form->getElement('firstname');
        
        $p = $fn->getPluginLoader('validate');
        print_r($p->getPaths());

.....

Will still output:

Array ( [Zend_Validate_] => Array ( [0] => Zend/Validate/ ) )

:wq
G



<validate>
<prefix>WETB_Validate</prefix>
<path>WETB/Validate</path>
<type>validate</type>
</validate>
</elementPrefixPaths>
<elements>
<title>
<type>select</type>
.....

Here is a snippet of the function I am then using to test:

function registerAction() {
$form = new Zend_Form($this->config->forms->userRegistration);
$fn = $form->getElement('firstname');
$p = $fn->getPluginLoader('validate');
print_r($p->getPaths());
.....

The print_r statement outputs:

Array ( [Zend_Validate_] => Array ( [0] => Zend/Validate/ ) )

I would expect this array to also contain the custom path.

In addition, the plugin loader throws an exception if I try to use a custom
validator class.

Any ideas?

:wq
Greg.

--
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to