Validation and Setting value for Multi-value fields Consider for a content type, there is a text field with multiple values capability activated.


How can I check its values by $form_state inside the Validate/Submit function?
How can I set its values by $form_state inside the Validate/Submit function?


The single code line for each of them would be enough for me to see, Thanks.

Further discussion:

I need to set/check the MULTI-VALUE fields' values. It's related to the DELTA value and ... but I don't know how clearly I can do it!
Clearly, for any multi-value field there is a delta value inside each fields' table in Drupal Database, which corresponds to the index of the value for that entity instance.

According to this knowledge, the structure of the form_state variable for a multi-value field with two values (e.g. X and Y) is:

[field_FIELD_NAME] =&gt; Array
                (
                    [und] =&gt; Array
                        (
                            [0] =&gt; Array
                                (
                                    [value] =&gt; X
                                    [_weight] =&gt; 0
                                )
                            [1] =&gt; Array
                                (
                                    [value] =&gt; Y
                                    [_weight] =&gt; 0
                                )

                            [add_more] =&gt; Add another item
                        )

                )


[0] and [1] are delta values for each value of this filed in the corresponding entity instance. For setting the values of a multi-value filed in FORM submit/validate hook, you should do as follows (consider again we have two values X and Y):

$form_state['values']['field_FIELD_NAME']['und'][0]=array("value"=&gt;'X',"_weight"=&gt;0);
$form_state['values']['field_FIELD_NAME']['und'][1]=array("value"=&gt;'Y',"_weight"=&gt;1);


The above lines ought to be written inside the VALIDATE hook. 

For reading values for validation, do as follows:

$values=$form_state['values']['field_FIELD_NAME']['und'];

foreach ($values as $key =&gt; $value) {
  if($value['value']...
}