Hello Tina, I am back.
I have analyzed this, for ease I used the non-ajax filter in the tests as well, since the DOC states that you can validate the Image Fields as well with it.
Simply the cred_form_validate() $fields array does not hold any 'file_data' value.
If you var_dump() $fields of your custom field, you will see that it is an array of:
value, name, type, repetitive.
That's it. There is no 'file_data' at all, as the Documented code sample wrongly states.
This does not depend on wether it is a repeating or single field.
In cred_form_validate there is definitely no 'file_data' at all.
To be honest I have no idea how you would be supposed to validate the size of that field, since this value is simply never present in any of the hooks.
The DOC says it shall be:
$fields['wpcf-my_field']['file_data'] = array(
'size' => uploaded file size,
'name' => name of uploaded file,
'type' => type of uploaded file,
'error' => what error occurred during upload,
'tmp_name' => location of temporary uploaded file
);
Well, as a simple test shows, this is false.
What we have is:
$fields['wpcf-my_field'] = array(
'value' => file_name,
'name' => field_name,
'type' => internal_cred_field_type,
'repetitive' => if repetitive (0/1),
'plugin_type' => from types?,
'validation' => array (
'url2' => array (
'active' => 1/0,
'message' => 'Please enter a valid URL address pointing to the image file.' (length=60)
'suppress_for_cred' => true
)
)
)
That's all. I see no file_data at all.
I have reported this problem to the Developers.
The issue with the index you also see, is so far expected, since we have several repeating instances you get an array instead of a single value.
But, it does not work according what is documented.
I will ask the developers to fix this and also revise the documentation.
Right now I have no solution.