[support] Rendering form instead of individual fields exhausts memory
Jeff Greenberg
listmail.ayendesigns at gmail.com
Thu Nov 7 03:49:51 UTC 2013
I have the following in a custom module
function email_subscription_block_view($delta) {
$content = '';
switch ($delta) {
case 'subscribe':
$content = drupal_get_form('email_subscription_form');
}
$subject = NULL;
return array('subject' => $subject, 'content' => $content);
}
function email_subscription_theme() {
return array(
'email_subscription_form' => array(
'arguments' => array('form' => NULL),
'render element' => 'form',
'template' => 'block--email-subscription',
),
);
}
function email_subscription_form($form, &$form_state) {
$form['email'] = array(
'#type' => 'textfield',
'#size' => 15,
'#maxlength' => 128,
'#required' => TRUE,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('sign up'),
);
$form['#theme'][] = 'email_subscription_form';
return $form;
}
In my template I have the following:
<div id="email-subscription">
<form id="email-subscription-form" class="email_subscription_form form">
<?php print render($form['email']);?>
<?php print render($form['submit']);?>
</form>
</div>
With this the two elements of the form render properly. If, instead I have:
<div id="email-subscription">
<form id="email-subscription-form" class="email_subscription_form form">
<?php print render($form);?>
</form>
</div>
I get a wsod and the log saying memory was exhausted.
--
---
drupal.org/user/367108
linkedin.com/in/jeffrgreenberg
accidentalcoder.com / ayendesigns.com
@accidentalcoder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20131106/15d7ac6a/attachment.html
More information about the support
mailing list