Closed (fixed)
Project:
Drupal core
Version:
6.x-dev
Component:
documentation
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
12 Oct 2006 at 16:59 UTC
Updated:
9 May 2008 at 21:14 UTC
Jump to comment: Most recent file
http://api.drupal.org/api/head/function/form_set_value
Use this function to make changes to form values in the form validate phase, so they will be available in the submit phase in $form_values.
Ok, with you so far...
Specifically, if $form['#parents'] is array('foo', 'bar') and $value is 'baz' then this function will make $form_values['foo']['bar'] to be 'baz'.
Um. What? o_0 #parents? $value? Eh?
We should probably have a source code example, since this is one of our trickier functions for new users to grok.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | drupal-6-88892.patch | 2.68 KB | steven jones |
| #8 | form_set_value-docs-88892-8.patch | 2.67 KB | floretan |
| #7 | HEAD-88892.patch | 2.69 KB | steven jones |
Comments
Comment #1
mpare commentedI made a comment over on another node with people, including myself, who have been having some difficulty with this function. Hope this helps. http://drupal.org/node/160160#comment-258277
Peace,
-mpare
www.paretech.com
Did you figure out how to do something? Did you find documentation on Drupal.org inadequate? Well now it's your turn. Document your Success!
Comment #2
ricabrantes commentedClose, no activity...
Comment #3
webchickJust because there's been no activity doesn't mean this isn't still a bug. ;)
Comment #4
webchickComment #5
floretan commentedThe few places in core where this function gets called are pretty obscure and wouldn't provide new developers with a useful example. A little difference that might make a big impact is renaming the $form parameter to $element to make it clear that we are setting the value of a form element, not the value of the form itself (which wouldn't make much sense).
Comment #6
steven jones commentedI will write something up in a bit...
Comment #7
steven jones commentedChanged the function's documentation and changed the name of one of the function's parameters to better reflect what it actually is.
Comment #8
floretan commentedThis is great. Thank you darthsteven.
I would just rephrase the documentation for the $value parameter (see attached patch), otherwise this looks good.
Comment #9
steven jones commentedLooks good, lets get this in, then backport.
Comment #10
dries commentedCommitted to CVS HEAD. Thanks! Keep it coming. :)
Comment #11
steven jones commentedNot sure what the procedure is for this, but here's the same documentation for D6.
Comment #12
gábor hojtsyThanks, I think this is a great addition to Drupal 6, so committed there too.
Comment #13
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.