简体   繁体   中英

Which is correct $form_state['values'] or $form_state['input']?

I used ajax to populate dependent fields and rebuild the field structure but in this whole process $form_state['values'] get erased but $form_state['input'] keeps the values through out the process and functionality works properly using $form_state['input'] .

I am working on contribute module and while doing review using pareview.sh it suggest me to use $form_state['values'] instead of $form_state['input'] . But in most of the scenarios I didn't get required values in $form_state['values'] .

Please suggest me what should I do to resolved those warnings in pareview.sh?

As far as I know, all the values get submitted by the form are stored inside $form_state['values'] array.

Try using var_dump($form_state['values']); to get an idea of what fields are getting submitted.

You can check here for more informations about form state keys -> https://www.drupal.org/node/1850410

To keep simple

$form_state['values'] // POST sanitized data

$form_state['input'] // POST raw data

There is a discussion here : https://www.drupal.org/node/1250172

Do you implement your ajax call with form api ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM