Set value field before submit I'm trying to set a value before the form is submitted. The field is calculated by two other fields. One of them is a property of an entity reference. This is what I do:

function nodeoverlay_node_submit($node, $form, &amp;$form_state) {
    if($node-&gt;type == 'zoekertje')
    {
        $korting = $form['field_field_korting']['und'][0]['value']['#value'];
        $node = field_get_items('node', $node, 'field_product_zoekertje');
        $node = node_load($node[0]['target_id']);
        $aankooprijs = $node-&gt;field_aankoopprijs['und'][0]['safe_value'];
        $price = floatval($aankooprijs - (($aankooprijs/100)*$korting));

        $form['field_verkoopprijs']['und'][0]['value']['#value'] = $price;
        $form['field_verkoopprijs']['und'][0]['value']['#default_value'] = $price;

        $form_state['field']['field_verkoopprijs']['und']['instance']['default_value'] = $price;
        $form_state['values']['field_verkoopprijs']['und'][0]['value'] = $price;
    }
}


I've tried different things to set my value of the field field_verkoopprijs but the result is always empty (and yes, my $price variable contains a float variable).

What can I do?
From hook_node_submit():


  This hook is intended for adjusting non-field-related properties


I think the proper place for this will be hook_node_presave() . To change field there you need to set, for example:

$node-&gt;some_field_name[LANGUAGE_NONE][0]['value'] = 'your value';


If you want to set reference field then:

$node-&gt;some_reference_field_name[LANGUAGE_NONE][0]['target_id'] = 'your value';


You may also want to consider using computed_field module for this.