I have a form with images. It also contains title and alt for 3 languages, so when I select them in one query, I get the same managed file fid 3 times. But that's not the problem.
Relevant part of code is:
kpr($image_has_language);
$first_language = reset($image_has_language);
$form['image'][$i] = array (
'#type' => 'fieldset',
'#collapsible' => FALSE,
'ImageFile' => array(
'#type' => 'managed_file',
'#default_value' => (integer)$first_language['ImageFile'],
'#title' => t("Image"),
'#title_display' => 'invisible',
// '#description' => t('Allowed extensions: gif png jpg jpeg.'),
'#upload_validators' => array(
'file_validate_extensions' => array('gif png jpg jpeg'),
'file_validate_size' => array(variable_get('something_image_size', 5 * 1024 * 1024)),
),
'#upload_location' => 'public://something/image',
'#theme' => 'preview_upload',
),
'id_image' => array(
'#type' => 'value',
'#value' => $clone?'new':$first_language['idImage'],
)
);
kpr($form['image'][$i]);
Below results of that kpr
s:
As you can see, all is perfectly well. File is on disk, file preview work, in database it is marked as permanent and as used.
When I call var_dump
on $form_state['values']['image'][0]
in validation function, without changing file on the form, I get:
array(3) { ["ImageFile"]=> int(0) ["id_image"]=> string(3) "599" }
Values in $_POST
are OK:
["image"]=> array(4) { [0]=> array(2) { ["ImageFile"]=> array(1) { ["fid"]=> string(4) "3696" }
If I change file, it works as expected:
array(3) { ["ImageFile"]=> string(4) "3698" ["id_image"]=> string(3) "599" }
and in $_POST
:
["image"]=> array(4) { [0]=> array(2) { ["ImageFile"]=> array(1) { ["fid"]=> string(4) "3698" }
How can I identify where my value gets removed? I also have another image on that form, single one (so without foreach
), and it works OK.