Greetings
I have the following notice when trying to use the webform as a block with display mode set to "Form only".
Notice: Undefined property: stdClass::$content in webform_block_view() (line 1759 of webform.module).
Which in turn, doesn't render the form. Clearing cache, fixes it for a while, but after some time or form submissions back to "Notice" without the form.
In general, after the 7.21 Core update I had a lot of problems with undefined property and unfortunately, one of them was with the webform block.
I've checked line 1759 and the problem is on "$content = $node->content['webform']"
// Generate the content of the block based on display settings.
if ($settings['display'] == 'form') {
webform_node_view($node, 'full');
$content = $node->content['webform'];
}
I am not sure why it has such a problem, but after a search I start to think that the culprit is my custom .tpl files.
Haven't check it yet.
Any help will be appreciated.
Thank you.
Comment | File | Size | Author |
---|---|---|---|
#8 | webform_check_block-1968434.patch | 767 bytes | quicksketch |
#7 | webform_check_block-1968434.patch | 540 bytes | quicksketch |
Comments
Comment #1
cyper983 CreditAttribution: cyper983 commentedHi, try to rewrite the code above with this, it worked for me!!
Comment #2
谢艳 CreditAttribution: 谢艳 commentedbecause there is no any forms in your new webform, so stdClass::$content is null!!
Comment #3
crutch CreditAttribution: crutch commentedJust encountered same. Was working before but now when viewing page with block form, getting the same error. Also, block has disappeared from block list so can't find it to do anything with it. Flush cache has no effect.+ Webform is not available in content list and it states "There are currently no webforms on your site." @admin/content/webform
solution #1 didn't fixapologies, we had a feed overwriting NIDs
Comment #4
Collins405 CreditAttribution: Collins405 commentedI am now having this problem as well, the site was working fine until I added a new basic page, and the error started showing.
I am using webform 4, and managed to stop the error showing from post 1.
In webform 4, the error appears for line 2032 of webform.module.
I changed it to the following, and the errors stopped. What's weird is that there wasn't a webform in a block, or even a webform on the only page the error was showing on.
Comment #5
bittu.rohan CreditAttribution: bittu.rohan commentedWell, I just logged in to say THANK YOU to you guys to posting a resolution to this issue.
I faced the same issue all of a sudden today when I am really almost done with my project. You saved my project...
Thanks again guys !
Yes, the above code worked for me...
Comment #6
itbazar CreditAttribution: itbazar commentedThank you!
Comment #7
quicksketchI guys, I'm not sure how this error is possible to reproduce. It seems like you'd have this problem only if your site had been misconfigured, or you previously had a Webform node in a block but then later deleted the form. Anyway, suppressing the notice is easy enough, so I've wrapped it in an isset() check as suggested by @chriscollins405.
Comment #8
quicksketchActually, I found that the approach in #7 would just result in a different PHP notice if Contextual module was disabled, so I used this approach to set the $content variable to an empty array instead of NULL to prevent errors.
Comment #10
fenstratNeeds porting to 8.x-4.x.
Comment #11
fenstratCommitted 4025004 to 8.x-4.x.