I'm calling drupal_render
to render a textarea element in another element's #prefix
field in hook_form_customtype_node_form_alter()
. When I load the form, most of the script tags in the header do not get printed. If I comment out the line with drupal_render
they print out and the accordions and sliders load on the page.
Why would calling drupal_render
prevent some of the javascript files from being included in the page header?
UPDATE
Here's my code:
$deltas = preg_grep('/^[0-9]*$/', array_keys($form['field_recommendation_reference'][LANGUAGE_NONE]));
foreach ($deltas as $delta) {
if ($form['field_recommendation_reference'][LANGUAGE_NONE][$delta]['field_key']['#default_value']['finding_wrapper'] == $wrapper_field_name) {
$wrapper = $form[$wrapper_field_name];
$wrapper['#printed'] = FALSE;
$wrapper['#value'] = 'test';
//$form[$field]['#suffix'] = drupal_render($wrapper);
dpm(drupal_render($wrapper));
}
}
When I output the element with dpm, the form loads all of the javascript. Also, when I include the markup without using drupal_render, the page loads correctly.
If I included the rendered markup manually the form doesn't load all of the javascript. Could it be a conflict with id's being used already? I have the same element stored in the $form array but with #printed set to TRUE.
Found the Issue
if I set #autocomplete_path = '', the form element's markup does not disrupt the rest of the page. Is it possible to get autocomplete to work with drupal render? I saw some comments related to this on the drupal_render api documentation
drupal_render
on a form element inside a form alter hook. The element will be rendered later on when the rest of the form is rendered, the form builder/alter functions are there to build the form. It's not that surprising that you're seeing strange behaviour when doing this