Folks,
The upgrading themes and modules to 4.7 pages have been largely helpful.
I'm working on porting the CivicSpace theme (my derivate is a layout) to 4.7
and I've gotten a decent bit done. The FORMS API bit is where I am at.
I used the FormsUpdater to convert the civicspace function
phptemplate_comment_form to 4.7 compatible. (in template.php)
Problem: when I click the add comment link to a node, I now get a new error which
does not look like a form_* related (4.6) error, but it is an error in drupal_get_form().
**
Fatal error: Unsupported operand types in /home/.olympia/editors/bopnetwork.org/includes/form.inc on line 87
**
Here are the last 4 lines of the updated function. It's failing in the call
inside drupal_get_form which much return the form HTML to $output.
~~
$form['#method'] = 'post';
$form['#action'] = url('comment/reply/'. $edit['nid']);
$output = drupal_get_form('comment_form', $form);
return theme('box', $title, $output);
~~
The line in form.inc is within the function drupal_get_form() where the
failure is happening. It is this:
~~
$form += _element_info('form');
~~
Can someone tell me what's going on? I've told the CivicSpace folks that
I will make this work for my site and then hand off the changes/patches
to them for 4.7. Appreciate any help. I can post the whole converted function
here if you want.
thanks.
-S
(p.s. two other folks have seen this for cac_lite and tac_lite but those threads
don't seem to have a resolution for this issue.)
Comments
Yes please
Please post the whole $form array (or the whole converted function).
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.
Ok
I'm replying to myself here, because the code is very long, and better left at the bottom.
I'm certainly not a forms api expert, but I believe your approach is fundamentally flawed(*). You're actually trying to build a form in a theme function, where you should only output HTML. drupal_get_form calls your theme function to get the form rendered, but instead you call it again, if _element_info didn't fail, you'd get a lot of recursion.
$edit actually contains the entire forms array from comment_form().
Try
It's possible to render individual form fields, see for example http://drupal.org/node/47582
(*) That means, it doesn't make sense to me.
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.
forward
Thanks for the tip. I think I'm moving in the direction here. I've been using the regular FormsAPI documentation and didn't read enough of the distinction betwee theme related Forms API and module related Forms API.
I changed the code to
This makes that unsupported operands problem go away, and a new warning comes up:
~~~
warning: uasort(): The argument should be an array in /home/.olympia/editors/bopnetwork.org/includes/form.inc on line 455.
~~~
The $form being passed is an array, and the complaint is coming from
form_render()'s fourth line itself the uasort() function.
Importantly, the comment form itself does not render at the
bottom of the story. A box with 'Reply' title gets put out and
here's the HTML I see in view source.
(I could not figure how to post the HTML into the comment box here,
to box code got rendered by mistake here, sorry!)
It seems that even though form_render is the correct API that theme functions
must call, perhaps something went wrong in the form array setup. Any advice
will help greatly. Thanks again for the key tip.
[fixed tags - Heine]
Don't assign to $form
I should have expressed myself clearer. You do not need to built the form array in phptemplate_comment_form anymore; it comes prebuilt. The only thing you have to do is generate output.
To see for yourself, modify the function:
function phptemplate_comment_form($form) {
var_dump($form);
?>
As you can see #method and #action are already defined.
PS You can post HTML between <code> tags.
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.
got it.
Appreciate that, it's working and now the commenting form renders and I can post/reply. I think I got the hang of this now. comment.module is already filling out everything like you said and it is calling drupal_get_form() and then itself calls theme('box', $title...) et al. So in 4.7 phptemplate_comment_form, needs to be much simpler it seems, and only has to invoke form_render() and return the output.
Here's the function that worked like you said:
I'm getting some warning on the screen now
~~
warning: implode(): Bad arguments. in /path/to/site/themes/sitetheme/template.php on line 386.
~~
It's happening in the function phptemplate_links($links, $delimiter = ' · ').
It looks like many/all of the phptemplate_XXXX functions in template.php for
civicspace need to be revised for 4.7. I've been using the Converting
theme from 4.6 to 4.7 note in http://drupal.org/node/25297 as a guide,
but it's not enough. I'd be happy to update that page when I'm done porting.
In anycase, I'll post a consolidated note there at least.
many thanks, again.
Slightly OT
If you keep it this simple:
Then you can just use the defaults, if I'm not mistaken.
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.
yes
Yes. I commented out the entire function phptemplate_comment_form() and
the form still renders the cleanly. So much for simplicity.
-S
now what?
Hi,
can anyone tell me what I have to change now in the form.in? i am getting this error:
Fatal error: Unsupported operand types in /home/www-data/htdocs/hannibalector/art/includes/form.inc on line 88the same error as you got. i read all comments, but i just don't understand what i have to change.
the error appears when i'm trying to comment:
http://hannibalector.redio.de/art/?q=comment/reply/9#comment_form
may you help me? thx.
edit: i changed my template.php as shown in your comment of the 27th april.
Here's the modifed function.
Here's the modifed function.
The original function is in template.php with the
civicspace theme that distributed with 4.6.x (It has a cvs line: /* $Id: template.php,v 1.8.2.5 2005/11/30 21:06:47 robinmonks Exp $ */)
resolved
A note to say that the primary issue raised in this thread was resolved, thanks in no small part to Heine.