I am trying to change the value of a text area field at the end of my submit handler. I have tried using form_set_value and $form['form_id']['#value'] = 'something'; to accomplish this but after clicking the submit button the field never changes. Also the submit button that I am trying to change the field with comes from the file managed form. I also included $form_state['rebuild'] = true; after I set the field's value. Here is my code

function my_module_my_form_submit($form,&$form_state) {

//do something with then file code


$form_set_value($form['value_to_change'], 'update the value, $form_state);

//I also tried

$form['value_to_change']['#value'] = 'update the value';

$form_state['rebuild'] =TRUE

In the form my code is

$form['value_to_change'] = array(
'#type' = 'text area',
'#value' => 'this will change',
  • Try $form_state['values']['YOURFIELD'] it should be working – niksmac Jun 4 '13 at 2:01
  • 1
    Generally accepted place for changing form is validator, not submit handler. Is there any particular reason to do it on submit? – Mołot Jun 4 '13 at 9:12

Just stumbled upon this and it's pretty dead so here's the answer in case OP still cares... turns out @Mołot is right.

The correct way to programatically change a form's submitted value is actually during validation and not during submission.

If you go back and re-read the documentation for form_set_value(), you'll notice that it explicitly says:

Changes submitted form values during form validation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.