By Fiasst on
Hi, I've struck a problem with a custom comments form in my template.php.
The error I'm getting is: 'warning: implode() [function.implode]: Bad arguments. in /var/www/vhosts/drupalsnippets.com/httpdocs/includes/form.inc on line 621.'
Heres the code I'm using. Can you see any problems?
Note: The comment-theme-form.tpl simply contains: ' print drupal_render($form); ' with some html wrapped around it.
function phptemplate_comment_form($form) {
$form['comment_filter']['format'] = array();
$form['_author'] = array();
$form['preview'] = array();
$form['comment_filter']['comment'] = array(
'#type' => 'textarea',
'#title' => t('Add revisions, bug reports, feedback and questions for this snippet'),
'#description' => t('Wrap any code in the appropriate language ‹tags›.'),
'#rows' => 5,
'#id' => 'edit-comment',
'#name' => 'comment',
'#default_value' => $edit['comment'] ? $edit['comment'] : $user->signature,
'#required' => TRUE
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Post comment'),
'#id' => 'comment-submit',
'#class' => 'form-submit',
'#name' => 'op',
'#weight' => 20
);
return _phptemplate_callback('comment-theme-form', array('form' => $form));
}
Thanks for looking,
Marc
Comments
A guess
My guess it is these three lines
The simple approach would be to unset the fields instead (ex:
unset($form['preview'] );)But for 'format' and '_author' may need values (you would need to look at the submit code) in which case you want to use either a type of 'value' or 'hidden' with the value you want to be used.
Thanks for your reply, I've
Thanks for your reply, I've adjusted my code - shown below.
However, I've noticed the error disappears when I comment out the '$form['comment_filter']['comment']' (textarea) section of my code. I've tried to comment out each item of the array to try and find the trouble spot but it seems to be the entire textarea section that causes the error.
Any ideas?
Thanks! :)
warning implode message
your warning implode is coming from these lines in form.inc lines 613-626
one of your elements has an error and when it goes to implode the #parents of the element it returns a warning because the #parents argument does not exist. I'm not sure what causes the form to trigger this error, but if you are sure your form is working correctly and just need to get rid of the message you can add the #parents param to your form elements it will eliminate the warning display.
ie..
Without deviation from the norm, progress is not possible. - Frank Zappa
hello, i just found this and
hello,
i just found this and this is exactly what i need. but if i add the parents param to the template.php i get an syntax error in this line. what am i doing wrong? i just copied the code above.