Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293442

Changes to $form_state['values'] are not reflected on form rebuild

$
0
0

Try this code:

<?php
function MYMODULE_myform($form, &$form_state) {
 
$form['myfield'] = array(
   
'#type'=> 'textfield',
   
'#title'=> 'MyField',
  );
 
$form['actions'] = array('#type'=> 'actions');
 
$form['actions']['submit'] = array(
   
'#type'=> 'submit',
   
'#value'=> t('Submit'),
  );
  return
$form;
}

function
MYMODULE_myform_submit($form, &$form_state) {
 
$form_state['values']['myfield'] = 'my value';
 
$form_state['rebuild'] = TRUE;
}
?>

When submitting, I expect form to get rebuilt showing 'my value' as value for field myfield.
But it does not work.
It seems that $form_state['values'] is not used but $form_state['input'].
This is not documented anywhere.
What are supposed to do if we want to change values between form submit and form rebuild then?


Viewing all articles
Browse latest Browse all 293442

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>