Adding properties to form values...


Hi, I have been trying to figure out how subobjects work. Documentation doesn't help me much with the questions: Do I need 2 templates or does it work in only 1? How do I add the properties?

I did the following (simplified), which seems to work:

Box (main) template:

Description: {{{Description|}}}
{{#ask: [[Is part of box::{{PAGENAME}}]] |?Has amount |?Has item |format=table |mainlabel=-}}

Item template:

{{#set: Has amount={{{NUMBER|}}}}} {{#set: Has item={{{ITEM|}}} }}
{{#subobject: |Has item={{{ITEM|}}} |Has amount={{{NUMBER|}}} |Is part of box={{PAGENAME}} }}


{{{for template|Box}}}
{{{end template}}}

{{{for template|Item|multiple}}}
{{{end template}}}

My question now is: Is this somewhat correct? And is there any other way to add the properties (Has item, has amount) to the values (in the item template) instead of setting them silently with #set? If I add them simply with [[Has amount::{{{NUMBER|}}}]] [[Has item::{{{ITEM|}}}]] they will show additionally to the output of the#ask query, which is unintentional, because it's double.

19:00, 16 October 2014

Yes, you need two templates, one for the page and one for the subobjects since there are supposed to be several different items in the box. So you will need to use the multi instance form.

Do not add #set in the item template since you are already passing the respective values to the subobject. I prefer setting all values into the subobject via the form, e.g. by additionally adding {{{field|BOX|hidden|default={{PAGENAME}} }}} but that's probably a matter of habit. Thus I believe it is easier to grasp which values are actually annotated via the subobject.

15:46, 18 October 2014