Last modified: 2013-04-12 02:22:34 UTC
I have a "embed in field" template that has a single dropdown field that is used to "show on select" certain div sections each containing the same "for template|templateName" except with different fields but all contain a "holds template|hidden" field to hold the value of the dropdown and used in the template later. The problem is the dropdown template prints it's value into the free-text section for all of the hidden divs (hidden because the dropdown does not select/show them). Each edit prints a new set of dropdown values and they interfere with the form display if the dropdown is ever changed not to mention outputting to the page itself. Here is the simplified code: Form ==== <div class="create-form-section-inner" id="journal-article-form"> {{{for template |CreateRefObject |sourceType={{SusFormType |sourcetype}} }}} ===Cite Journal Article=== {{{field |sourceType |holds template |hidden}}} {| ! | Author*: | {{{field|journal-author}}} |} {{{end template}}} </div> <div class="create-form-section-inner" id="news-article-form"> {{{for template |CreateRefObject |sourceType={{SusFormType |sourcetype}} }}} ===Cite News Article=== {{{field |sourceType |holds template |hidden}}} {| ! | News Author*: | {{{field|news-author}}} |} {{{end template}}} </div> {{{for template |SusFormType |embed in field=CreateRefObject[sourceType] |label=Source Type}}} {| ! Select the type of source to cite*: |{{{field|sourcetype|input type=dropdown |default=News Article |values=News Article, Journal Article,Video |show on select=News Article=>news-article-form; Journal Article=>journal-article-form; Video=>video-form|mandatory }}} |} {{{end template}}} SusFormType Template ==================== <noinclude> Description... </noinclude><includeonly>{{{sourcetype|}}}</includeonly> The documentation doesn't have any examples on how to use "embed in field" and related parameters, so I could be using them wrong, but everything works except for the combo value printouts and also it seems like if a field is declared hidden, then it should not be printing anything out on the page.
P.S. I added the |sourceType={{SusFormType |sourcetype}} part later while troubleshooting but really isn't needed (probably wrong) and without the same problem exists.
I should probably state what I'm trying to do. I'm simply trying to set the "sourceType" fields with the value of the dropdown. This works, but the dropdown value for all the hidden divs get printed out to the page. Specifically, the whole template of the dropdown get's placed in the free-text section like so: {{SusFormType |sourcetype=News Article }} {{SusFormType |sourcetype=Journal Article }}{{SusFormType |sourcetype=Journal Article }}{{SusFormType |sourcetype=Journal Article }}
I workaround seems to be to not duplicate the form template in each div, but to keep all the selectable divs inside one template block that they pertain to.
There may be other issues with the form, but one that I see right away is that you shouldn't have more than "for template" tag for the same template. Even if only one is meant to be viewed at any given time, it's still not allowed.
Thanks for the clarification Yaron. Closing...