Issue #2355001 by ashutoshsngh, dinarcon, er.pushpinderrana: Remove form.inc form_builder().

8.0.x
Nathaniel Catchpole 2014-10-14 13:54:17 +01:00
parent a9f0c068cb
commit e8d6588e14
9 changed files with 22 additions and 30 deletions

View File

@ -2541,7 +2541,8 @@ function drupal_prepare_page($page) {
* the defaults for this type of element, defined in hook_element_info(), * the defaults for this type of element, defined in hook_element_info(),
* are merged into the array. #defaults_loaded is set by functions that * are merged into the array. #defaults_loaded is set by functions that
* process render arrays and call element_info() before passing the array to * process render arrays and call element_info() before passing the array to
* drupal_render(), such as form_builder() in the Form API. * drupal_render(), such as \Drupal::formBuilder()->doBuildForm() in the
* Form API.
* - If this element has an array of #pre_render functions defined, they are * - If this element has an array of #pre_render functions defined, they are
* called sequentially to modify the element before rendering. After all the * called sequentially to modify the element before rendering. After all the
* #pre_render functions have been called, #printed is checked a second time * #pre_render functions have been called, #printed is checked a second time

View File

@ -84,18 +84,6 @@ function form_execute_handlers($type, &$form, FormStateInterface $form_state) {
} }
} }
/**
* Builds and processes all elements in the structured form array.
*
* @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
* Use \Drupal::formBuilder()->doBuildForm().
*
* @see \Drupal\Core\Form\FormBuilderInterface::doBuildForm().
*/
function form_builder($form_id, &$element, FormStateInterface $form_state) {
return \Drupal::formBuilder()->doBuildForm($form_id, $element, $form_state);
}
/** /**
* Removes internal Form API elements and buttons from submitted form values. * Removes internal Form API elements and buttons from submitted form values.
* *
@ -520,7 +508,8 @@ function template_preprocess_form_element(&$variables) {
$element = &$variables['element']; $element = &$variables['element'];
// This function is invoked as theme wrapper, but the rendered form element // This function is invoked as theme wrapper, but the rendered form element
// may not necessarily have been processed by form_builder(). // may not necessarily have been processed by
// \Drupal::formBuilder()->doBuildForm().
$element += array( $element += array(
'#title_display' => 'before', '#title_display' => 'before',
); );

View File

@ -1147,8 +1147,8 @@ class FormState implements FormStateInterface {
->unsetValue('op'); ->unsetValue('op');
// Remove button values. // Remove button values.
// form_builder() collects all button elements in a form. We remove the button // \Drupal::formBuilder()->doBuildForm() collects all button elements in a
// value separately for each button element. // form. We remove the button value separately for each button element.
foreach ($this->getButtons() as $button) { foreach ($this->getButtons() as $button) {
// Remove this button's value from the submitted form values by finding // Remove this button's value from the submitted form values by finding
// the value corresponding to this button. // the value corresponding to this button.

View File

@ -35,7 +35,7 @@ abstract class RenderElement extends PluginBase implements ElementInterface {
} }
// This function is invoked from form element theme functions, but the // This function is invoked from form element theme functions, but the
// rendered form element may not necessarily have been processed by // rendered form element may not necessarily have been processed by
// form_builder(). // \Drupal::formBuilder()->doBuildForm().
if (!empty($element['#required'])) { if (!empty($element['#required'])) {
$element['#attributes']['class'][] = 'required'; $element['#attributes']['class'][] = 'required';
$element['#attributes']['required'] = 'required'; $element['#attributes']['required'] = 'required';

View File

@ -1493,9 +1493,9 @@ function template_preprocess_file_managed_file(&$variables) {
* Upload controls are hidden when a file is already uploaded. Remove controls * Upload controls are hidden when a file is already uploaded. Remove controls
* are hidden when there is no file attached. Controls are hidden here instead * are hidden when there is no file attached. Controls are hidden here instead
* of in file_managed_file_process(), because #access for these buttons depends * of in file_managed_file_process(), because #access for these buttons depends
* on the managed_file element's #value. See the documentation of form_builder() * on the managed_file element's #value. See the documentation of
* for more detailed information about the relationship between #process, * \Drupal::formBuilder()->doBuildForm() for more detailed information about the
* #value, and #access. * relationship between #process, #value, and #access.
* *
* Because #access is set here, it affects display only and does not prevent * Because #access is set here, it affects display only and does not prevent
* JavaScript or other untrusted code from submitting the form as though access * JavaScript or other untrusted code from submitting the form as though access

View File

@ -76,12 +76,12 @@ class TextFormat extends RenderElement {
// Ensure that children appear as subkeys of this element. // Ensure that children appear as subkeys of this element.
$element['#tree'] = TRUE; $element['#tree'] = TRUE;
$blacklist = array( $blacklist = array(
// Make form_builder() regenerate child properties. // Make \Drupal::formBuilder()->doBuildForm() regenerate child properties.
'#parents', '#parents',
'#id', '#id',
'#name', '#name',
// Do not copy this #process function to prevent form_builder() from // Do not copy this #process function to prevent
// recursing infinitely. // \Drupal::formBuilder()->doBuildForm() from recursing infinitely.
'#process', '#process',
// Description is handled by theme_text_format_wrapper(). // Description is handled by theme_text_format_wrapper().
'#description', '#description',

View File

@ -26,7 +26,8 @@ class RenderWebTest extends WebTestBase {
public static $modules = array('common_test'); public static $modules = array('common_test');
/** /**
* Tests rendering form elements without passing through form_builder(). * Tests rendering form elements without passing through
* \Drupal::formBuilder()->doBuildForm().
*/ */
function testDrupalRenderFormElements() { function testDrupalRenderFormElements() {
// Define a series of form elements. // Define a series of form elements.

View File

@ -137,11 +137,11 @@ function views_ui_add_limited_validation($element, FormStateInterface $form_stat
$element['#limit_validation_errors'] = array($ajax_triggering_element['#parents']); $element['#limit_validation_errors'] = array($ajax_triggering_element['#parents']);
// If we are in the process of a form submission and this is the button that // If we are in the process of a form submission and this is the button that
// was clicked, the form API workflow in form_builder() will have already // was clicked, the form API workflow in \Drupal::formBuilder()->doBuildForm()
// copied it to $form_state->getTriggeringElement() before our #process // will have already copied it to $form_state->getTriggeringElement() before
// function is run. So we need to make the same modifications in $form_state // our #process function is run. So we need to make the same modifications in
// as we did to the element itself, to ensure that #limit_validation_errors // $form_state as we did to the element itself, to ensure that
// will actually be set in the correct place. // #limit_validation_errors will actually be set in the correct place.
$clicked_button = &$form_state->getTriggeringElement(); $clicked_button = &$form_state->getTriggeringElement();
if ($clicked_button && $clicked_button['#name'] == $element['#name'] && $clicked_button['#value'] == $element['#value']) { if ($clicked_button && $clicked_button['#name'] == $element['#name'] && $clicked_button['#value'] == $element['#value']) {
$clicked_button['#limit_validation_errors'] = $element['#limit_validation_errors']; $clicked_button['#limit_validation_errors'] = $element['#limit_validation_errors'];

View File

@ -1156,7 +1156,8 @@ class ViewEditForm extends ViewFormBase {
} }
/** /**
* Recursively adds microweights to a render array, similar to what form_builder() does for forms. * Recursively adds microweights to a render array, similar to what
* \Drupal::formBuilder()->doBuildForm() does for forms.
* *
* @todo Submit a core patch to fix drupal_render() to do this, so that all * @todo Submit a core patch to fix drupal_render() to do this, so that all
* render arrays automatically preserve array insertion order, as forms do. * render arrays automatically preserve array insertion order, as forms do.