Note that there are some explanatory texts on larger screens.

plurals
  1. POZend_Form password confirmation with .ini config - Can it be done?
    primarykey
    data
    text
    <p>I set out writing a ZF (v1.10.3) application and chose to use Zend_Config_Ini to generate my Zend_Form objects. This was all well and good until I had to test for identical password inputs. This is the part that's misbehaving right now:</p> <pre><code>elements.password.type = password elements.password2.type = password elements.password2.options.validators.identical.validator = "Identical" elements.password2.options.validators.identical.options.token = password </code></pre> <p>Instead of comparing the values of these two elements, it compares password2's value against the literal string "password". So any password except "password" gives me the following validation error:</p> <pre><code>The token 'password' does not match the given token '*******' </code></pre> <p>Is there a right way to do this? The only example of using Zend_Validate_Identical with Zend_Config_Ini that I found via Google was from a German website, and someone appeared to recommend the exact same "solution" as my failing code above.</p> <p>I know there are plenty of ways to do this in PHP code, but I've committed myself pretty heavily to INI configuration at this point, and I'd rather not abandon it or make an exception unless I absolutely have to.</p> <p>[EDIT] Here is my full newUserForm.ini:</p> <pre><code>method = "post" id = "newUserForm" accept-charset = "utf-8" elements.username.type = "text" elements.username.options.label = "Username" elements.username.options.required = true elements.username.options.validators.alnum = "Alnum" elements.username.options.validators.strlen.validator = "StringLength" elements.username.options.validators.strlen.options.min = "3" elements.username.options.validators.strlen.options.max = "32" elements.email.type = "text" elements.email.options.label = "Email address" elements.email.options.required = true elements.email.options.validators.email.validator = "EmailAddress" elements.password.type = "password" elements.password.options.label = "Password" elements.password.options.required = true elements.password.options.validators.strlen.validator = "StringLength" elements.password.options.validators.strlen.options.min = "6" elements.password2.type = "password" elements.password2.options.label = "Password (confirm)" elements.password2.options.required = true elements.password2.options.validators.identical.validator = "Identical" elements.password2.options.validators.identical.options.token = password elements.submit.type = "submit" elements.submit.options.label = "Submit" </code></pre> <p>And here is my controller action:</p> <pre><code>public function indexAction() { $formConfig = new Zend_Config_Ini(APPLICATION_PATH.'/configs/newUserForm.ini'); $newUserForm = new Zend_Form($formConfig); $request = $this-&gt;getRequest(); if ($request-&gt;isPost()) { if ($newUserForm-&gt;isValid($request-&gt;getPost())) { // create new user here $this-&gt;_helper-&gt;redirector('index', 'index'); } } $this-&gt;view-&gt;newUserForm = $newUserForm; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload