I have a form and i want to pass some values without user see them.
At the beginning i was using the default values:
$form['field_devis_lien_fiche']['und'][0]['value']["#default_value"] = t("@path",array("@path" => $path));
It was working fine but it's not the behavior i wanted because all the user could see the value.
So i buy "pro drupal 7 developpment" and at page 283, he describe the element value and i think this is what i have to use.
$form['title'] = array(
"#type" => 'value',
"#value" => $titre,
);
$form['field_devis_lien_fiche'] = array(
"#type" => 'value',
"#value" => $path,
);
The $form['title'] works fine but all my other fields trigger an error.
Warning: array_values() [function.array-values]: The argument should be an array in _field_filter_items() (line 517 of ***/modules/field/field.module).
Warning: Invalid argument supplied for foreach() in text_field_validate() (line 119 of ***/modules/field/modules/text/text.module).
Notice: Undefined index: #language in locale_field_node_form_submit() (line 405 of ***/modules/locale/locale.module).
When i want to edit my content type, my value doesn't exist.
So i tried another solution with the hidden element:
$form['title'] = array(
"#type" => 'hidden',
"#value" => $titre,
);
$form['field_devis_lien_fiche'] = array(
"#type" => 'hidden',
"#value" => $path,
);
In spit of the fact that my hidden fields are created when i inspect the form, i have the same error again (with array_value problem)
i don't understand why it's works for the title field and why it's not working for my other field. And i don't understand too, why i have an error with the hidden field as they appears well when i inspect element with firefox.
Do i have to create a validation function because of my element value? Maybe i have forgotten a step...
Thanks for the help.