Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#16025 closed task (invalid)

Templated form throws "target is null" exception unless attach point given : dijit/_TemplatedMixin, dijit/form/Form, dijit/Dialog, dijit/layout/ContentPane, on.js:42

Reported by: bishop Owned by: bill
Priority: undecided Milestone: tbd
Component: Dijit Version: 1.8.0
Keywords: Cc:
Blocked By: Blocking:


Looks like a form created from a template needs to have an attach point in the template, while div created from template or form created with dom construction do not.

The example problem code goes like this:

new Dialog({content:new TemplateForm()}, 'container').show();

// where "TemplateForm" is like:
    [ 'dojo/_base/declare', 'dijit/_WidgetBase', 'dijit/_TemplatedMixin', 'dijit/form/Form' ],
    function ( declare, WidgetBase, TemplatedMixin, Form) {
        return declare([WidgetBase, TemplatedMixin, Form], {
            templateString:'<form><div><p>I am just a form (no attach point).</p></div></form>'

But neither a template with a div root node nor a form created with domConstruct.create('form', {innerHTML:'...'}); need an attach point.

I've scoured the docs and sitepen in case there was some exception with templated forms, including:

but I can't find any. So, if form legitimately needs an attach point when templated then I think the docs need clarification. If form shouldn't need it, then some code needs tweaking (though not sure if it's template mixin or form).

Attached is some code evoking these paths.

Attachments (1) (2.9 KB) - added by bishop 7 years ago.

Download all attachments as: .zip

Change History (6)

Changed 7 years ago by bishop

Attachment: added

comment:1 Changed 7 years ago by ben hockey

Owner: changed from bill to bishop
Status: newpending

you need to fix up your examples - they are not equal comparisons. once you fix them i think you'll find that they all need an attach point.

  • PlainForm?.js doesn't extend dijit/form/Form so is not an equal comparison - it should fail when you change it
  • TemplateDiv_Sans_AttachPoint.js, doesn't extend dijit/form/Form so is not an equal comparison - it should fail when you change it
  • TemplateDiv_With_AttachPoint.js, also doesn't extend dijit/form/Form - it should work when you change it
  • TemplateForm_Sans_AttachPoint.js, extends dijit/form/Form but does not have an attach point - this should fail as it does
  • TemplateForm_With_AttachPoint.js, extends dijit/form/Form and works because it has an attach point

i haven't confirmed what i'm saying here but if you fix your example and there are problems then someone will take a look.

comment:2 Changed 7 years ago by bishop

Status: pendingnew

Ok, whoops, PlainForm? did indeed need to extend Form ... which I did and yep it broke.

But the TemplateDiv? ones should not extend form, since I want them to be rooted on a <div> to illustrate my point: extending Form requires attach point, extending WidgetBase? does not, and this doesn't appear to be in the documentation.

Assuming attach point just is required for Form extensions, then I propose re-categorizing this ticket as into the documentation component.

comment:3 Changed 7 years ago by ben hockey

Owner: changed from bishop to bill
Status: newassigned
Type: defecttask

there are many widgets that require certain attach points that need to be considered if you override their templates - and none of this is explicitly documented. it's been expected that developers can look at the template they are overriding and figure out what it provides to the widget and make sure that the new template is suitable.

i'm passing to bill to decide if this ticket needs to remain open. documenting all the attach points would take quite a big effort initially and could turn into a lot of maintenance so i'll leave it to him to decide if it's something he wants to do.

comment:4 Changed 7 years ago by ben hockey

Resolution: invalid
Status: assignedclosed

actually... this particular case is already covered by the API docs.

In templated widgets, "containerNode" is set via a data-dojo-attach-point assignment.

i'm closing out this ticket since the docs already address your issue.

comment:5 Changed 7 years ago by bishop

Hmm, didn't see that. Thanks for the link.

I would only recommend changing the verbiage "is set via" to "must be set via".

Last edited 7 years ago by bishop (previous) (diff)
Note: See TracTickets for help on using tickets.