Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3443915
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-3443915
Commits
e8998ea0
Commit
e8998ea0
authored
15 years ago
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#570314
by jhodgdon: more details for form_set_value() documentation.
parent
1cb3f94a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
includes/form.inc
+19
-15
19 additions, 15 deletions
includes/form.inc
with
19 additions
and
15 deletions
includes/form.inc
+
19
−
15
View file @
e8998ea0
...
...
@@ -1620,27 +1620,31 @@ function form_type_token_value($element, $input = FALSE) {
}
/**
* Change submitted form values during
the
form
processing cycle
.
* Change submitted form values during form
validation
.
*
* Use this function to change the submitted value of a form
item in the
* validation
phase so that it
persists in $form_state
through to the
*
submission handlers in
the submission
p
has
e
.
* Use this function to change the submitted value of a form
element in a form
* validation
function, so that the changed value
persists in $form_state
*
through to
the submission ha
ndler
s.
*
* Since $form_state['values'] can either be a flat array of values, or a tree
* of nested values, some care must be taken when using this function.
* Specifically, $element['#parents'] is an array that describes the branch of
* the tree whose value should be updated. For example, if we wanted to update
* $form_state['values']['one']['two'] to 'new value', we'd pass in
* $element['#parents'] = array('one', 'two') and $value = 'new value'.
* Note that form validation functions are specified in the '#validate'
* component of the form array (the value of $form['#validate'] is an array of
* validation function names). If the form does not originate in your module,
* you can implement hook_form_FORM_ID_alter() to add a validation function
* to $form['#validate'].
*
* @param $element
* The form item that should have its value updated. Keys used: #parents,
* #value. In most cases you can just pass in the right element from the $form
* array.
* The form element that should have its value updated; in most cases you can
* just pass in the element from the $form array, although the only component
* that is actually used is '#parents'. If constructing yourself, set
* $element['#parents'] to be an array giving the path through the form
* array's keys to the element whose value you want to update. For instance,
* if you want to update the value of $form['elem1']['elem2'], which should be
* stored in $form_state['values']['elem1']['elem2'], you would set
* $element['#parents'] = array('elem1','elem2').
* @param $value
* The new value for the form
item
.
* The new value for the form
element
.
* @param $form_state
*
Th
e array where the value change should be recorded.
*
Form stat
e array where the value change should be recorded.
*/
function
form_set_value
(
$element
,
$value
,
&
$form_state
)
{
_form_set_value
(
$form_state
[
'values'
],
$element
,
$element
[
'#parents'
],
$value
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment