Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3421017
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-3421017
Commits
875e99be
Commit
875e99be
authored
18 years ago
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#88109
by Eaton, chx et al: FormAPI 2.0 doesn't support dynamic form ids.
parent
1afb654e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
includes/form.inc
+25
-4
25 additions, 4 deletions
includes/form.inc
with
25 additions
and
4 deletions
includes/form.inc
+
25
−
4
View file @
875e99be
...
...
@@ -163,11 +163,31 @@ function drupal_execute($form_id, $form_values) {
function
drupal_retrieve_form
(
$form_id
)
{
static
$forms
;
// We save two copies of the incoming arguments: one for modules to use
// when mapping form ids to builder functions, and another to pass to
// the builder function itself. We shift out the first argument -- the
// $form_id itself -- from the list to pass into the builder function,
// since it's already known.
$args
=
func_get_args
();
$saved_args
=
$args
;
array_shift
(
$args
);
// We first check to see if there's a function named after the $form_id.
// If there is, we simply pass the arguments on to it to get the form.
if
(
!
function_exists
(
$form_id
))
{
if
(
!
isset
(
$forms
))
{
$forms
=
module_invoke_all
(
'forms'
);
// In cases where many form_ids need to share a central builder function,
// such as the node editing form, modules can implement hook_forms(). It
// maps one or more form_ids to the correct builder functions.
//
// We cache the results of that hook to save time, but that only works
// for modules that know all their form_ids in advance. (A module that
// adds a small 'rate this comment' form to each comment in a list
// would need a unique form_id for each one, for example.)
//
// So, we call the hook if $forms isn't yet populated, OR if it doesn't
// yet have an entry for the requested form_id.
if
(
!
isset
(
$forms
)
||
!
isset
(
$forms
[
$form_id
]))
{
$forms
=
module_invoke_all
(
'forms'
,
$saved_args
);
}
$form_definition
=
$forms
[
$form_id
];
if
(
isset
(
$form_definition
[
'callback arguments'
]))
{
...
...
@@ -177,14 +197,15 @@ function drupal_retrieve_form($form_id) {
$callback
=
$form_definition
[
'callback'
];
}
}
// $callback comes from a hook_forms() implementation
// If $callback was returned by a hook_forms() implementation, call it.
// Otherwise, call the function named after the form id.
$form
=
call_user_func_array
(
isset
(
$callback
)
?
$callback
:
$form_id
,
$args
);
// We store the original function arguments, rather than the final $arg
// value, so that form_alter functions can see what was originally
// passed to drupal_retrieve_form(). This allows the contents of #parameters
// to be saved and passed in at a later date to recreate the form.
$form
[
'#parameters'
]
=
func_get
_args
()
;
$form
[
'#parameters'
]
=
$saved
_args
;
return
$form
;
}
...
...
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