Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Even after the node_get_types bug (patch attached) is removed, the node add form doesn't work. There is a whole list of errors, all similar to this one (full list attached):
# Warning: Attempt to assign property of non-object in node_form() (line 92 of /modules/node/node.pages.inc).
The panel page (apart from the errors) shows "Form goes here" where the form is supposed to be.
Comment | File | Size | Author |
---|---|---|---|
#40 | node_add_form_fix-1012722-40.patch | 1.32 KB | Letharion |
#38 | node_add_form_fix-1012722-4936908.patch | 1.32 KB | bochen87 |
#36 | node_add_form_fix-1012722-4842508.patch | 1.23 KB | bochen87 |
#35 | node_add_form_fix-1012722-4841692.patch | 860 bytes | bochen87 |
node_get_types.patch | 847 bytes | burlap |
Comments
Comment #1
merlinofchaos CreditAttribution: merlinofchaos commentedCommitted and pushed upstream. I think I've got node forms more or less working now.
Comment #3
wjaspers CreditAttribution: wjaspers commentedSeems to be a problem again.
It looks like the
node_form()
function expects $node to be an object, but doesn't explicitly look for it that way.On a node/edit page these forms work just fine, but if you try to put them into a page as a Context elsewhere they don't work.
Comment #4
ann_meredith CreditAttribution: ann_meredith commentedsubscribe
Comment #5
logaritmisk CreditAttribution: logaritmisk commentedsubscribe
Comment #6
rogical CreditAttribution: rogical commentedcan't use, I also created a issue on panels http://drupal.org/node/1166840
the panels can't retrieve 'title field' which is required on form submit.
Comment #7
rafhuys CreditAttribution: rafhuys commentedsubscribe
Comment #8
merlinofchaos CreditAttribution: merlinofchaos commentedwjaspers: I can't duplicate what you're seeing. It might be something specific to what you've got set up? Can you walk me through what I need to do to get that error?
Comment #9
Itangalo CreditAttribution: Itangalo commentedMe thinks this issue is related to #1109048: Can't select node type in context "Node add form". For the record.
Comment #10
mr.andrey CreditAttribution: mr.andrey commentedI'm getting the same errors with latest dev of ctools and panels.
A.
Comment #11
SNaKeMe CreditAttribution: SNaKeMe commentedsubscribe
Comment #12
wjaspers CreditAttribution: wjaspers commented@merlin, I triggered this by adding the "Node add/edit" form as a Context to a normal "Node/%node" Page. Then, I put it on the page panel. When you try to view the page, those are the errors you (should) get.
Comment #13
inolen CreditAttribution: inolen commentedJust tried to place an add node form on a custom page and I'm receiving the same errors (also, I'm just seeing 'form goes here').
Update: Modified ctools_context_create_node_add_form() to pass $node as an object instead of an array like so to get rid of all the errors:
However, then inside of ctools_form_content_type_render() it's using a different context I suppose, as $context->form isn't set resulting in it printing out "Form goes here."
I'm not really familiar with how the context system works, so if anyone can point me in the right direction from here I'd appreciate it :)
Comment #14
wjaspers CreditAttribution: wjaspers commentedI wouldn't modify the ctools_context_create call to explicitly define what content-type you want to use. By doing so, you can severely limit CTools' ability to work properly.
You may have found the cause of this problem, though. If the Node context is supposed to be an object, and an array is being used, this could explain the slew of errors I saw. When I have more time, I'll look a little closer at it.
Comment #15
inolen CreditAttribution: inolen commentedDoh, sorry, that was just some bad copy and pasting action there. But still, there is the fact that the context used to render with in form.inc is not the same context that is generated in node_add_form.inc.
I feel like I must just be setting up something wrong.
I created a panels page, added a node add form context, then added a "node add form base form" to one of my panes and am stuck with "Form goes here."
Comment #16
inolen CreditAttribution: inolen commentedAlright, I dug myself into completely unfamiliar territory but I'll post up where I got.
It appears the problem is caused at the root by this piece of code:
Both ctools_context_handler_get_render_handler() and ctools_context_handler_render_handler() end up calling ctools_context_get_context_from_contexts(), which stores the results from ctools_context_create_node_add_form() into an array like so (context.inc line ~1092):
Finally, ctools_context_create_node_add_form() sets a static variable and early outs if called a second time, returning an empty array, causing the original context to be overwritten by a blank one.
I temporarily commented out the line in ctools_context_create_node_add_form() where it sets the static flag, however, I'm sure there is a more proper way to fix this, I just have absolutely no idea what it is.
Hope this helps.
Edit: Also, here are some callstack traces from inside of ctools_context_create_node_add_form() to further illustrate:
Call 1:
Call 2:
Comment #17
hunziker CreditAttribution: hunziker commentedsubscribe
Comment #18
hunziker CreditAttribution: hunziker commentedI trigger a bit down where the warnings come from. The problem is in file ./ctools/plugins/contexts/node_add_form.inc on line 60.
The problem is $node is an array, but the form wants an object. So you could cast the $node to an object and many of the notices and warnings disappear.
The $language notice can be also removed, when you add the $language key to the array defined in line 56.
This changes do not resolve the problem with the missing form. I get the any way the message "Form goes here.".
Comment #19
hunziker CreditAttribution: hunziker commentedThe general form (base form) is shown up when applying the changes mentioned in #16. I think the idea of the developer was to handler up the $context to the $contexts and in the second call the $context is already filled with the form.
One problem remains the entity fields are not shown up. Potentially because we do not handle the $context correct...
Comment #20
TimelessDomain CreditAttribution: TimelessDomain commentedPOST REMOVED (irrelevant)
Comment #21
ssjcory CreditAttribution: ssjcory commentedAny update on this? I'm experiencing this same issue... Not only does it not work for custom content types. It doesn't work for the basic "article" type either. I'll do some digging and see if I can find out anything useful... there sure are a ton of warnings though.
Comment #22
samhassell CreditAttribution: samhassell commentedsubscribe
Comment #23
ssjcory CreditAttribution: ssjcory commentedsubscribe
Comment #24
cajmcmahon CreditAttribution: cajmcmahon commentedSubscribing
Same errors when trying "Node edit form - Add context"
Warning: Attempt to assign property of non-object in node_form()
Notice: Trying to get property of non-object in node_object_prepare()
Notice: Trying to get property of non-object in node_form()
etc.
Panels 7.x-3.x-dev (June 01, 2011)
CTools 7.x-1.x-dev (2011-Jul-18)
Comment #25
merlinofchaos CreditAttribution: merlinofchaos commentedIt's weird, I thought these things had already been addressed, but apparently not. That piece of code was terribly unloved.
Committed a fix; the node add form context now seems to work correctly, and no longer generates notices.
Comment #26
ssjcory CreditAttribution: ssjcory commentedThank you very much merlinofchaos :) Your fix did the trick. I still see a warning on the page but it might be related to panels:
Notice: Undefined property: ctools_context::$id in panels_render_display() (line 1035 of /var/www/sites/all/modules/panels/panels.module)... It doesnt seem to break anything... it's just ugly on the screen :)
Comment #27
samhassell CreditAttribution: samhassell commentedI can report the same as ssjcory. Fixed the main issue but still getting
Notice: Undefined property: ctools_context::$id in panels_render_display() (line 1030 of /var/aegir/platforms/homes/sites/all/modules/contrib/panels/panels.module).
Comment #28
merlinofchaos CreditAttribution: merlinofchaos commentedI committed a fix to Panels earlier that fixes that warning. I saw it too when I was fixing this.
Comment #29
samhassell CreditAttribution: samhassell commentedrunning perfectly.
hopefully this is safe to close now.
Comment #30
hunziker CreditAttribution: hunziker commentedThe normal node does work, but the entity part does not work. So you can edit / create a node, but if you want to edit specific fields of the node you cant. (As in the special panel provided by panels.) The reason therefore is mentioned in #16 and #19.
Comment #31
merlinofchaos CreditAttribution: merlinofchaos commentedAs per #25, I committed a fix.
Comment #32
bochen87 CreditAttribution: bochen87 commentedHi
As per #30 it still doesn't work as supposed to:
If I add a "Node add form" as context, I don't get to choose the form elements of the chosen Node type but instead I get to choose the form elements of the Node type chosen in the selection rule.
For example if I add a "Node add form" context of content type Article to my variant, where I have chosen a Basic page in the selection rule, then I only get to choose the form elements of a Basic page and not the form elements of the Article.
Comment #33
merlinofchaos CreditAttribution: merlinofchaos commentedThat's a different bug and it already has an issue. No need to hijack this one. :(
Comment #34
bochen87 CreditAttribution: bochen87 commentedHi Merlinofchaos, seems to be a problem again. The bug described in #32 is fixed, but if I try to add form elements of my chosen content type, I get the following error:
Error message
Notice: Trying to get property of non-object in entity_extract_ids() (line 7379 of /opt/local/apache2/htdocs/drupal_development/includes/common.inc).
I tracked down the error to line 80 of entity_form_field.inc.
Comment #35
bochen87 CreditAttribution: bochen87 commentedTracked down the final error and created a patch for the latest dev version.
There was a mix up between entities and bundles.
Comment #36
bochen87 CreditAttribution: bochen87 commentedI noticed that the node add/edit templates do not work anymore with my previous patch, so created a new patch.
Comment #37
merlinofchaos CreditAttribution: merlinofchaos commentedMinor code style issue: Missing a space.
Otherwise this looks good. Reading the code I totally see what's wrong, but the if could probably use a comment for people who aren't plugged into the system. Something like:
// The node add context will have only the type for ->data so we have to make an entity
Or something along those lines. I guess we should make completely sure that's true, too.
Comment #38
bochen87 CreditAttribution: bochen87 commentedAdded the suggested changes. Would be nice if some people could test this and make sure that this works as supposed to.
Comment #39
nagiek CreditAttribution: nagiek commentedsubscribe
Comment #40
Letharion CreditAttribution: Letharion commentedPatch from #38 didn't apply for some reason, patch complained it was malformed.
It removed the long list of error messages and replaced it with a nice looking form though when applied manually, so I re-rolled it.
Comment #41
merlinofchaos CreditAttribution: merlinofchaos commentedI believe this patch is deprecated by #1395628: Node Add Form context missing node object.