The values at $element[#post] are now in $form_state['input']. I didn't see that documented anywhere.

Comments

arianek’s picture

Project: Documentation » Drupal core
Version: » 7.x-dev
Component: Correction/Clarification » documentation

moving to core docs queue - this may be dealt with by now.

tha_sun said (in IRC) $element['#post'] == $form_state['input'] now, but you never want to use 'input' directly, always use 'values'

jhodgdon’s picture

I don't see this documented on
http://drupal.org/update/modules/6/7
and it sounds like it should be?

jhodgdon’s picture

tagging

jhodgdon’s picture

Status: Active » Postponed (maintainer needs more info)

Does anyone have a clue about what issue this was introduced in? It's still not documented in the 6/7 module update guide.

sun’s picture

Status: Postponed (maintainer needs more info) » Active

#1 is correct.

$element['#post'] and $form['#post'] got removed in a major overhaul of Form API. That must have been early in the D7 cycle, as I didn't participate in that.

However, for 99.9% lines of code that need to be updated, it's:

D6:

  $values = $form['#post'];

D7:

  $values = $form_state['values'];

Note that $element['#post'] always contained the full $_POST, even though it was in $element (major WTF). To access the submitted values for a (possibly expanded/processed) element, there's no difference between D6 and D7:

  $values = $element['#value'];

For the sake of completeness, $form_state['values'] is not really identical to $element['#post']. The latter contained the unprocessed and not validated user input in D6. Usage of that data is generally discouraged, but if you absolutely need it, then it's available in $form_state['input'].

Lastly, aside from the major Form API overhaul, I guess that $element['#post'] was entirely removed, because it implies "POST", whereas forms can also support $form_state['method'] = 'GET';

sun’s picture

With the help @chx on IRC:

If you had a good, solid reason to use $form['#post'] or $element['#post'] then now you can use $form_state['input'].

However, processed values are available in $form_state['values'] and the element that triggered the form submission is in $form_state['triggering element'] and you are highly encouraged to use those. Never copy data from $form_state['input'] into the database.

Otherwise, use $element['#value'] or $form_state['values'].

jhodgdon’s picture

Status: Active » Fixed

Thanks - this information is now at
http://drupal.org/update/modules/6/7#element_post

Status: Fixed » Closed (fixed)
Issue tags: -Needs documentation updates

Automatically closed -- issue fixed for 2 weeks with no activity.