Okay, I am really struggling with this data validation with CakePHP. I'm using CakePHP 2.4.6. I have the following code snippets from the Models:
User.php:
public $validate = array(
'username' => array(
'alphanumeric' => array(
'rule' => array('alphanumeric'),
'required' => false,
'message' => 'Please provide your username to log in.'
),
),
'password' => array(
'required' => true,
'message' => 'Please provide your password to log in.'
),
);
Job.php:
public $validate = array(
'patterns_file' => array(
'extension' => array(
'rule' => array(
'extension', array('csv','txt'),
'message' => 'Please upload the patterns in CSV or TXT file.'
)
),
'uploadError' => array(
'rule' => 'uploadError',
'message' => 'Something went wrong with the upload.'
)
),
'xy_value' => array(
'rule' => array('allowEmpty', false),
'message' => 'Please select the xy_value.'
)
);
My first problem is not blocking but still disturbs me. Although I have set messages to the validation rules, non of them appear, only the default message is shown no matter how I set the 'message'. I just mention this because maybe it has something to do with my main problem which is the following:
In Firefox and Chrome the validation is working.
The username and password fields are for the login. They are shown like this in FF (and similar in Chrome):
There is a single drop-down list and File-upload validation in the Job's view, which are shown like this:
So it is working in FF (30.0) and Chrome (35.0), but it is not working in IE 9. I can easily press login and can easily submit my form without selecting anything from the drop-down list or uploading a file. No red-lighted background and no info bubble.
update 1: I have just checked it again and I was mistaken, the file-upload is only working on the aspect that there has to be uploaded something, but I can upload a file with any extension.