I was unable to get the form to display, even on a brand new drupal installation.
- when i checked the HTMLsource, I DID get form_token and form_id, but not the actual fields for name, address, comment,...:
<form action="/loesjeBE/node/3" accept-charset="UTF-8" method="post" id="ecard-form"> <div><input type="hidden" name="form_build_id" id="form-ddf667614cefff630b914401819c1e19" value="form-ddf667614cefff630b914401819c1e19" /> <input type="hidden" name="form_token" id="edit-ecard-form-form-token" value="1d0d75ad673f82e4a21fa69aa618a9fe" /> <input type="hidden" name="form_id" id="edit-ecard-form" value="ecard_form" /> </div></form>
I guess this means that drupal_get_form() does get called, but that something goes wrong there?
According to this, there should only be the $form_id as argument.
When i removed $node, the ecard form appeared as hoped.
The change i made was (line 265):
$node->content['ecard_form'] = array(
'#value' => drupal_get_form('ecard_form', $node),
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'ecard_form') : 100,
);
to this:
$node->content['ecard_form'] = array(
'#value' => drupal_get_form('ecard_form'),
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'ecard_form') : 100,
);
Can somebody check if this is the correct fix? Was there a reason why the reference to $node was there?
It's strange that this would be the cause, since this piece of code has been in ecard since version 1.0, and i know that 1.1 worked for me. But maybe it only started being a problem on more recent Drupal Core versions? (I'm now using 6.15)
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | ecard-test.png | 44.68 KB | tom_buytaert |
Comments
Comment #1
tom_buytaert commentedSorry.
Apparently this was the wrong solution. Removing the $node does make the form appear, but the ecard then doesn't know what node the ecard was attached to.
But I still have the problem that the form fields don't appear on my nodes. Anyone have a clue what could cause it? It does seem to have something to do with drupal_get_form.
Comment #2
tom_buytaert commentedWhat seems to work is if the ampersand ( & ) is removed on line 301:
function ecard_form($form_state, &$node) {changed to:
function ecard_form($form_state, $node) {Apparenly there must be some kind of problem with passing the $node by reference.
Comment #3
kars-t commentedHi Tom,
sorry for the delay. If I take a stage with an empty garland only activate ecard for "story" node type and add a story the form is there. And my simple test still tells me everything is okay.
Please give me more information on this issue.
Comment #4
tom_buytaert commentedHey Kars-T,
I just did an entirely new install again (drupal 6.15), downloaded and enabled ecard (ecard 1.7 - ecard.module,v 1.1.4.20 2009/12/22 19:27:11 karst), enabled story module on admin/settings/ecard, and created a story node. (I didn't do anything else)
When i did this, I got following error when I view this story node:
warning: Parameter 2 to ecard_form() expected to be a reference, value given in /home/username/public_html/ecarddrupal/includes/form.inc on line 372.(as you can see on the screenshot)
As I said in the first post, the form fields themselves do not appear, but the form_token and form_id fields are there.
When i delete the & from line 301 of the ecard module (see post #2), the ecard fields do appear.
I'm using
PHP 5.3.1
I also tested on another server, where I don't get this error, and the ecard form is working.
drupal 6.14
PHP 5.1.2
So maybe it could be something with the PHP version?
Comment #5
kars-t commentedGreat Thanks! Thats something with PHP 5.3. They handle the by reference stuff differently. I will look into this ASAP.
Comment #6
kars-t commentedI did read other issues about that and PHP 5.3 behaves differently here. Could you please remove the & so the function call in line 375 looks like this and tell me if it works?
Comment #7
kars-t commentedSetting this to "needs review"
Comment #8
tom_buytaert commentedThe & in ecard_validate_emails() doesn't seem to have any effect as far as I can see, and i don't get any errors with or without it.
Only the & in ecard_form($form_state, &$node) seems to matter.
Comment #9
kars-t commentedHuh, what did I do?
Ofcourse I mean line 301
I take this as "it works" and commit a new version now.
This maybe break PHP 4 support but really I don't care about that.