Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
847304a2
Commit
847304a2
authored
May 12, 2009
by
Dries Buytaert
Browse files
- Patch
#353069
by Moshe Weitzman, dmitrig01: make drupal_get_form() return unrendered forms.
parent
da87545c
Changes
21
Hide whitespace changes
Inline
Side-by-side
includes/common.inc
View file @
847304a2
...
...
@@ -3252,8 +3252,8 @@ function drupal_get_page($content = NULL) {
* @see drupal_get_page()
*/
function
drupal_render_page
(
$page
)
{
// Allow menu callbacks to return strings.
if
(
is_string
(
$page
))
{
// Allow menu callbacks to return strings
, or bare content arrays
.
if
(
is_string
(
$page
)
||
empty
(
$page
[
'content'
])
)
{
$page
=
drupal_get_page
(
$page
);
}
// Modules alter the $page as needed. Blocks are populated into regions like
...
...
includes/form.inc
View file @
847304a2
...
...
@@ -29,8 +29,8 @@
* presentation, while simplifying code and reducing the amount of HTML that
* must be explicitly generated by modules.
*
* The drupal_get_form() function handles retrieving
,
processing
,
an
d
*
displaying a rendered HTML
form for modules automatically. For example:
* The drupal_get_form() function handles retrieving
and
processing an
HTML
* form for modules automatically. For example:
*
* @code
* // Display the user registration form.
...
...
@@ -62,7 +62,7 @@
* example, the node_edit form requires that a node object is passed in here
* when it is called.
* @return
* The
rendered form
.
* The
form array
.
*
* @see drupal_build_form()
*/
...
...
@@ -78,12 +78,11 @@ function drupal_get_form($form_id) {
}
/**
* Build
, render,
and process a form based on a form id.
* Build and process a form based on a form id.
*
* The form may also be retrieved from the cache if the form was built in a
* previous page-load. The form is then passed on for processing, validation
* and submission if there is proper input, and then rendered for display
* if necessary.
* and submission if there is proper input.
*
* @param $form_id
* The unique string identifying the desired form. If a function with that
...
...
@@ -107,13 +106,6 @@ function drupal_get_form($form_id) {
* forms do not use form ids so are always considered to be submitted, which
* can have unexpected effects. The 'get' method should only be used on
* forms that do not change data, as that is exclusively the domain of post.
* - rerender: May be set to FALSE to force the form to not be re-rendered
* after submit. Ordinarily, forms are re-rendered after a successful submit
* if there is no redirect. However, many forms may want to perform some
* other action, but not necessarily re-render the form. This is
* particularly true when using AHAH or AJAX where some data may be returned
* to the calling JavaScript. Note that a form validation error will always
* re-render the form.
* - no_redirect: If set to TRUE the form will NOT perform a drupal_goto(),
* even if a redirect is set.
* - always_process: If TRUE and the method is GET, a form_id is not
...
...
@@ -181,10 +173,6 @@ function drupal_build_form($form_id, &$form_state) {
// altering the $form_state variable, which is passed into them by
// reference.
drupal_process_form
(
$form_id
,
$form
,
$form_state
);
// If we were told not to redirect, but not told to re-render, return here.
if
(
!
empty
(
$form_state
[
'executed'
])
&&
empty
(
$form_state
[
'rerender'
]))
{
return
;
}
if
(
$cacheable
&&
!
empty
(
$form
[
'#cache'
])
&&
empty
(
$form
[
'#no_cache'
]))
{
// Caching is done past drupal_process_form so #process callbacks can
...
...
@@ -210,10 +198,17 @@ function drupal_build_form($form_id, &$form_state) {
if
((
!
empty
(
$form_state
[
'storage'
])
||
!
empty
(
$form_state
[
'rebuild'
]))
&&
!
empty
(
$form_state
[
'submitted'
])
&&
!
form_get_errors
())
{
$form
=
drupal_rebuild_form
(
$form_id
,
$form_state
);
}
// Don't override #theme if someone already set it.
if
(
!
isset
(
$form
[
'#theme'
]))
{
init_theme
();
$registry
=
theme_get_registry
();
if
(
isset
(
$registry
[
$form_id
]))
{
$form
[
'#theme'
]
=
$form_id
;
}
}
// If we haven't redirected to a new location by now, we want to
// render whatever form array is currently in hand.
return
drupal_render_form
(
$form_id
,
$form
);
return
$form
;
}
/**
...
...
@@ -224,7 +219,6 @@ function form_state_defaults() {
'storage'
=>
NULL
,
'submitted'
=>
FALSE
,
'method'
=>
'post'
,
'rerender'
=>
TRUE
,
'programmed'
=>
FALSE
,
'groups'
=>
array
(),
);
...
...
@@ -678,31 +672,6 @@ function drupal_validate_form($form_id, $form, &$form_state) {
$validated_forms
[
$form_id
]
=
TRUE
;
}
/**
* Renders a structured form array into themed HTML.
*
* @param $form_id
* A unique string identifying the form for validation, submission,
* theming, and hook_form_alter functions.
* @param $form
* An associative array containing the structure of the form.
* @return
* A string containing the themed HTML.
*/
function
drupal_render_form
(
$form_id
,
&
$form
)
{
// Don't override #theme if someone already set it.
if
(
!
isset
(
$form
[
'#theme'
]))
{
init_theme
();
$registry
=
theme_get_registry
();
if
(
isset
(
$registry
[
$form_id
]))
{
$form
[
'#theme'
]
=
$form_id
;
}
}
$output
=
drupal_render
(
$form
);
return
$output
;
}
/**
* Redirect the user to a URL after a form has been processed.
*
...
...
includes/locale.inc
View file @
847304a2
...
...
@@ -158,9 +158,9 @@ function locale_languages_overview_form_submit($form, &$form_state) {
* User interface for the language addition screen.
*/
function
locale_languages_add_screen
()
{
$
output
=
drupal_get_form
(
'locale_languages_predefined_form'
);
$
output
.
=
drupal_get_form
(
'locale_languages_custom_form'
);
return
$
output
;
$
build
[
'predefined'
]
=
drupal_get_form
(
'locale_languages_predefined_form'
);
$
build
[
'custom'
]
=
drupal_get_form
(
'locale_languages_custom_form'
);
return
$
build
;
}
/**
...
...
@@ -564,7 +564,7 @@ function locale_translate_seek_screen() {
// Add CSS.
drupal_add_css
(
drupal_get_path
(
'module'
,
'locale'
)
.
'/locale.css'
,
array
(
'preprocess'
=>
FALSE
));
$output
=
drupal_get_form
(
'locale_translation_filter_form'
);
$output
=
drupal_render
(
drupal_get_form
(
'locale_translation_filter_form'
)
)
;
$output
.
=
_locale_translate_seek
();
return
$output
;
}
...
...
@@ -807,9 +807,9 @@ function locale_translate_export_screen() {
$output
=
''
;
// Offer translation export if any language is set up.
if
(
count
(
$names
))
{
$output
=
drupal_get_form
(
'locale_translate_export_po_form'
,
$names
);
$output
=
drupal_render
(
drupal_get_form
(
'locale_translate_export_po_form'
,
$names
)
)
;
}
$output
.
=
drupal_get_form
(
'locale_translate_export_pot_form'
);
$output
.
=
drupal_render
(
drupal_get_form
(
'locale_translate_export_pot_form'
)
)
;
return
$output
;
}
...
...
includes/theme.inc
View file @
847304a2
...
...
@@ -1824,7 +1824,7 @@ function template_preprocess_page(&$variables) {
$variables
[
'messages'
]
=
$variables
[
'show_messages'
]
?
theme
(
'status_messages'
)
:
''
;
$variables
[
'main_menu'
]
=
theme_get_setting
(
'toggle_main_menu'
)
?
menu_main_menu
()
:
array
();
$variables
[
'secondary_menu'
]
=
theme_get_setting
(
'toggle_secondary_menu'
)
?
menu_secondary_menu
()
:
array
();
$variables
[
'search_box'
]
=
(
theme_get_setting
(
'toggle_search'
)
?
drupal_get_form
(
'search_theme_form'
)
:
''
);
$variables
[
'search_box'
]
=
(
theme_get_setting
(
'toggle_search'
)
?
drupal_render
(
drupal_get_form
(
'search_theme_form'
)
)
:
''
);
$variables
[
'site_name'
]
=
(
theme_get_setting
(
'toggle_name'
)
?
variable_get
(
'site_name'
,
'Drupal'
)
:
''
);
$variables
[
'site_slogan'
]
=
(
theme_get_setting
(
'toggle_slogan'
)
?
variable_get
(
'site_slogan'
,
''
)
:
''
);
$variables
[
'css'
]
=
drupal_add_css
();
...
...
install.php
View file @
847304a2
...
...
@@ -212,7 +212,7 @@ function install_change_settings($profile = 'default', $install_locale = '') {
include_once
DRUPAL_ROOT
.
'/includes/form.inc'
;
install_task_list
(
'database'
);
$output
=
drupal_get_form
(
'install_settings_form'
,
$profile
,
$install_locale
,
$settings_file
,
$database
);
$output
=
drupal_render
(
drupal_get_form
(
'install_settings_form'
,
$profile
,
$install_locale
,
$settings_file
,
$database
)
)
;
drupal_set_title
(
st
(
'Database configuration'
));
print
theme
(
'install_page'
,
$output
);
exit
;
...
...
@@ -433,7 +433,7 @@ function install_select_profile() {
install_task_list
(
'profile-select'
);
drupal_set_title
(
st
(
'Select an installation profile'
));
print
theme
(
'install_page'
,
drupal_get_form
(
'install_select_profile_form'
,
$profiles
));
print
theme
(
'install_page'
,
drupal_render
(
drupal_get_form
(
'install_select_profile_form'
,
$profiles
))
)
;
exit
;
}
}
...
...
@@ -560,7 +560,8 @@ function install_select_locale($profilename) {
install_task_list
(
'locale-select'
);
drupal_set_title
(
st
(
'Choose language'
));
print
theme
(
'install_page'
,
drupal_get_form
(
'install_select_locale_form'
,
$locales
));
print
theme
(
'install_page'
,
drupal_render
(
drupal_get_form
(
'install_select_locale_form'
,
$locales
)));
exit
;
}
}
...
...
@@ -703,7 +704,7 @@ function install_tasks($profile, $task) {
// got accidentally blown somewhere. Stop it now.
install_already_done_error
();
}
$form
=
drupal_get_form
(
'install_configure_form'
,
$url
);
$form
=
drupal_render
(
drupal_get_form
(
'install_configure_form'
,
$url
)
)
;
if
(
!
variable_get
(
'site_name'
,
FALSE
)
&&
!
variable_get
(
'site_mail'
,
FALSE
))
{
// Not submitted yet: Prepare to display the form.
...
...
modules/comment/comment.admin.inc
View file @
847304a2
...
...
@@ -13,10 +13,10 @@ function comment_admin($type = 'new') {
$edit
=
$_POST
;
if
(
isset
(
$edit
[
'operation'
])
&&
(
$edit
[
'operation'
]
==
'delete'
)
&&
isset
(
$edit
[
'comments'
])
&&
$edit
[
'comments'
])
{
return
drupal_get_form
(
'comment_multiple_delete_confirm'
);
return
drupal_render
(
drupal_get_form
(
'comment_multiple_delete_confirm'
)
)
;
}
else
{
return
drupal_get_form
(
'comment_admin_overview'
,
$type
,
arg
(
4
));
return
drupal_render
(
drupal_get_form
(
'comment_admin_overview'
,
$type
,
arg
(
4
))
)
;
}
}
...
...
modules/comment/comment.module
View file @
847304a2
...
...
@@ -1626,7 +1626,7 @@ function comment_form(&$form_state, $edit, $title = NULL) {
* A string containing the box output.
*/
function
theme_comment_form_box
(
$edit
,
$title
=
NULL
)
{
$content
=
drupal_get_form
(
'comment_form'
,
$edit
,
$title
);
$content
=
drupal_render
(
drupal_get_form
(
'comment_form'
,
$edit
,
$title
)
)
;
$output
=
'<h2 class="title">'
.
$title
.
'</h2><div>'
.
$content
.
'</div>'
;
return
$output
;
}
...
...
modules/dblog/dblog.admin.inc
View file @
847304a2
...
...
@@ -47,8 +47,8 @@ function dblog_overview() {
WATCHDOG_EMERG
=>
'dblog-emerg'
,
);
$output
=
drupal_get_form
(
'dblog_filter_form'
);
$output
.
=
drupal_get_form
(
'dblog_clear_log_form'
);
$output
=
drupal_render
(
drupal_get_form
(
'dblog_filter_form'
)
)
;
$output
.
=
drupal_render
(
drupal_get_form
(
'dblog_clear_log_form'
)
)
;
$header
=
array
(
' '
,
...
...
modules/openid/openid.inc
View file @
847304a2
...
...
@@ -69,7 +69,7 @@ function openid_redirect_http($url, $message) {
*/
function
openid_redirect
(
$url
,
$message
)
{
$output
=
'<html><head><title>'
.
t
(
'OpenID redirect'
)
.
"</title></head>
\n
<body>"
;
$output
.
=
drupal_get_form
(
'openid_redirect_form'
,
$url
,
$message
);
$output
.
=
drupal_render
(
drupal_get_form
(
'openid_redirect_form'
,
$url
,
$message
)
)
;
$output
.
=
'<script type="text/javascript">document.getElementById("openid-redirect-form").submit();</script>'
;
$output
.
=
"</body></html>
\n
"
;
print
$output
;
...
...
modules/openid/openid.pages.inc
View file @
847304a2
...
...
@@ -54,7 +54,7 @@ function openid_user_identities($account) {
}
$output
=
theme
(
'table'
,
$header
,
$rows
);
$output
.
=
drupal_get_form
(
'openid_user_add'
);
$output
.
=
drupal_render
(
drupal_get_form
(
'openid_user_add'
)
)
;
return
$output
;
}
...
...
modules/poll/poll.module
View file @
847304a2
...
...
@@ -567,14 +567,10 @@ function poll_view($node, $teaser = FALSE, $block = FALSE) {
}
if
(
!
empty
(
$node
->
allowvotes
)
&&
(
$block
||
empty
(
$node
->
show_results
)))
{
$node
->
content
[
'body'
]
=
array
(
'#markup'
=>
drupal_get_form
(
'poll_view_voting'
,
$node
,
$block
),
);
$node
->
content
[
'poll_view_voting'
]
=
drupal_get_form
(
'poll_view_voting'
,
$node
,
$block
);
}
else
{
$node
->
content
[
'body'
]
=
array
(
'#markup'
=>
poll_view_results
(
$node
,
$teaser
,
$block
),
);
$node
->
content
[
'poll_view_results'
]
=
array
(
'#markup'
=>
poll_view_results
(
$node
,
$teaser
,
$block
));
}
return
$node
;
}
...
...
modules/search/search.module
View file @
847304a2
...
...
@@ -175,7 +175,7 @@ function search_block_list() {
*/
function
search_block_view
(
$delta
=
''
)
{
if
(
user_access
(
'search content'
))
{
$block
[
'content'
]
=
drupal_get_form
(
'search_block_form'
);
$block
[
'content'
]
=
drupal_render
(
drupal_get_form
(
'search_block_form'
)
)
;
$block
[
'subject'
]
=
t
(
'Search'
);
return
$block
;
}
...
...
modules/search/search.pages.inc
View file @
847304a2
...
...
@@ -40,7 +40,7 @@ function search_view($type = 'node') {
}
// Construct the search form.
$output
=
drupal_get_form
(
'search_form'
,
NULL
,
$keys
,
$type
);
$output
=
drupal_render
(
drupal_get_form
(
'search_form'
,
NULL
,
$keys
,
$type
)
)
;
$output
.
=
$results
;
return
$output
;
...
...
modules/simpletest/tests/form_test.module
View file @
847304a2
...
...
@@ -70,13 +70,13 @@ function form_test_menu() {
}
/**
* Generate a page with three form, to test the clean_id generation.
* Generate a page with three form
s
, to test the clean_id generation.
*/
function
form_test_form_clean_id_page
()
{
$
output
=
drupal_get_form
(
'form_test_test_form'
);
$
output
.
=
drupal_get_form
(
'form_test_test_form'
);
$
output
.
=
drupal_get_form
(
'form_test_test_form'
);
return
$
output
;
$
build
[
'form_test_test_form1'
]
=
drupal_get_form
(
'form_test_test_form'
);
$
build
[
'form_test_test_form2'
]
=
drupal_get_form
(
'form_test_test_form'
);
$
build
[
'form_test_test_form3'
]
=
drupal_get_form
(
'form_test_test_form'
);
return
$
build
;
}
/**
...
...
@@ -335,7 +335,7 @@ function form_storage_test_form(&$form_state) {
);
}
else
{
$form
[
'
content
'
]
=
array
(
'#value'
=>
'This is the second step.'
);
$form
[
'
body
'
]
=
array
(
'#value'
=>
'This is the second step.'
);
$form
[
'submit'
]
=
array
(
'#type'
=>
'submit'
,
'#value'
=>
'Save'
,
...
...
modules/system/system.admin.inc
View file @
847304a2
...
...
@@ -1084,11 +1084,11 @@ function system_ip_blocking() {
);
}
$
output
.
=
drupal_get_form
(
'system_ip_blocking_form'
);
$
build
[
'system_ip_blocking_form'
]
=
drupal_get_form
(
'system_ip_blocking_form'
);
$
output
.
=
theme
(
'table'
,
$header
,
$rows
);
$
build
[
'system_ip_blocking_table'
]
=
array
(
'#markup'
=>
theme
(
'table'
,
$header
,
$rows
)
)
;
return
$
output
;
return
$
build
;
}
/**
...
...
modules/system/system.module
View file @
847304a2
...
...
@@ -1709,7 +1709,7 @@ function system_actions_manage() {
}
if
(
$actions_map
)
{
$output
.
=
drupal_get_form
(
'system_actions_manage_form'
,
$options
);
$output
.
=
drupal_render
(
drupal_get_form
(
'system_actions_manage_form'
,
$options
)
)
;
}
return
$output
;
...
...
modules/taxonomy/taxonomy.admin.inc
View file @
847304a2
...
...
@@ -64,6 +64,7 @@ function taxonomy_overview_vocabularies_submit($form, &$form_state) {
*/
function
theme_taxonomy_overview_vocabularies
(
$form
)
{
$rows
=
array
();
foreach
(
element_children
(
$form
)
as
$key
)
{
if
(
isset
(
$form
[
$key
][
'name'
]))
{
$vocabulary
=
&
$form
[
$key
];
...
...
modules/trigger/trigger.admin.inc
View file @
847304a2
...
...
@@ -21,17 +21,17 @@ function trigger_assign($type = NULL) {
drupal_goto
(
'admin/build/trigger/node'
);
}
$
output
=
''
;
$
build
=
array
()
;
$hooks
=
module_invoke_all
(
'hook_info'
);
foreach
(
$hooks
as
$module
=>
$hook
)
{
if
(
isset
(
$hook
[
$type
]))
{
foreach
(
$hook
[
$type
]
as
$op
=>
$description
)
{
$form_id
=
'trigger_'
.
$type
.
'_'
.
$op
.
'_assign_form'
;
$
output
.
=
drupal_get_form
(
$form_id
,
$type
,
$op
,
$description
[
'runs when'
]);
$
build
[
$form_id
]
=
drupal_get_form
(
$form_id
,
$type
,
$op
,
$description
[
'runs when'
]);
}
}
}
return
$
output
;
return
$
build
;
}
/**
...
...
modules/user/user.admin.inc
View file @
847304a2
...
...
@@ -12,18 +12,18 @@ function user_admin($callback_arg = '') {
switch
(
$op
)
{
case
t
(
'Create new account'
)
:
case
'create'
:
$
output
=
drupal_get_form
(
'user_register'
);
$
build
[
'user_register'
]
=
drupal_get_form
(
'user_register'
);
break
;
default
:
if
(
!
empty
(
$_POST
[
'accounts'
])
&&
isset
(
$_POST
[
'operation'
])
&&
(
$_POST
[
'operation'
]
==
'cancel'
))
{
$
output
=
drupal_get_form
(
'user_multiple_cancel_confirm'
);
$
build
[
'user_multiple_cancel_confirm'
]
=
drupal_get_form
(
'user_multiple_cancel_confirm'
);
}
else
{
$
output
=
drupal_get_form
(
'user_filter_form'
);
$
output
.
=
drupal_get_form
(
'user_admin_account'
);
$
build
[
'user_filter_form'
]
=
drupal_get_form
(
'user_filter_form'
);
$
build
[
'user_admin_account'
]
=
drupal_get_form
(
'user_admin_account'
);
}
}
return
$
output
;
return
$
build
;
}
/**
...
...
modules/user/user.module
View file @
847304a2
...
...
@@ -138,7 +138,7 @@ function user_external_load($authname) {
* TRUE if the login succeeds, FALSE otherwise.
*/
function
user_external_login
(
$account
,
$edit
=
array
())
{
$form
=
drupal_get_form
(
'user_login'
);
$form
=
drupal_render
(
drupal_get_form
(
'user_login'
)
)
;
$state
[
'values'
]
=
$edit
;
if
(
empty
(
$state
[
'values'
][
'name'
]))
{
...
...
@@ -1099,7 +1099,7 @@ function user_block_view($delta = '') {
if
(
!
$user
->
uid
&&
!
(
arg
(
0
)
==
'user'
&&
!
is_numeric
(
arg
(
1
))))
{
$block
[
'subject'
]
=
t
(
'User login'
);
$block
[
'content'
]
=
drupal_get_form
(
'user_login_block'
);
$block
[
'content'
]
=
drupal_render
(
drupal_get_form
(
'user_login_block'
)
)
;
}
return
$block
;
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment