views:

127

answers:

5
+5  A: 
    'password' => array (
            'alphaNumeric' => array (
                    'on' => 'create',
                    'required' => false,
                    'error' => 'Alphabets and numbers only'
            ),
            'alphaNumeric' => array (
                    'on' => 'update',
                    'required' => false,
                    'error' => 'Alphabets and numbers only'
            )
    ),

You have two array entries with the same key. One of them will end up overwritten.

bdonlan
+3  A: 

This is a nitpicky comment, but you should declare your constructor using:

public function __construct() {

Anywho, I ran the code and it output the following:

Array
(
    [email] => email
    [password] => Array
        (
            [alphaNumeric] => Array
                (
                    [on] => update
                    [required] => 
                    [error] => Alphabets and numbers only
                )

        )

    [currentpassword] => Array
        (
            [alphaNumeric] => Array
                (
                    [on] => update
                    [required] => 
                    [error] => Alphabets and numbers only
                )

        )

    [newpassword] => Array
        (
            [alphaNumeric] => Array
                (
                    [on] => update
                    [required] => 
                    [error] => Alphabets and numbers only
                )

        )

)

You have two identical keys.

Andrew Noyes
+2  A: 

You are using the key 'alphaNumeric' twice. My guess is that the first value, the part that you quoted, is simply overridden by the second pair with the key 'alphaNumeric'. You cannot use duplicate keys in PHP arrays.

molf
+2  A: 

You have duplicate keys in your array. I am linking the Array documentation of PHP but after screening through it I couldnt find anywhere it saying that keys must be unique. BUT, it should be quite obvious :p

A possible approach would be to use :

            'alphaNumeric' => array (
                    'on' => array('create','update'),
                    'required' => false,
                    'error' => 'Alphabets and numbers only'
            ),
JPCosta
+2  A: 

You overwrite the first array in $this->form['password']['alphaNumeric'] with the second, so only the second will remain set.

George Crawford