https://bugzilla.wikimedia.org/show_bug.cgi?id=30011

       Web browser: ---
             Bug #: 30011
           Summary: Limited nested form capability
           Product: MediaWiki extensions
           Version: any
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: Unprioritized
         Component: SemanticForms
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]
    Classification: Unclassified


Created attachment 8816
  --> https://bugzilla.wikimedia.org/attachment.cgi?id=8816
Patched SF_FormPrinter, based on 2.2

This enhancement is a continuation of this upgrade:


http://www.mediawiki.org/wiki/Extension_talk:Semantic_Forms/Archive_February_to_March_2011#Copying_a_form_result_into_an_another_on_submission

And is thus a solution to the following situation, when one want to have fields
in a template that are themselves populated by a list of templates, and want to
be able to edit that using "nested multiple forms".

http://www.mediawiki.org/wiki/Extension_talk:Semantic_Forms/Archive_September_to_October_2010#Nested_forms

The logic is to have in the main form a hidden field with a "placeholder"
attribute. Then, a multiple-instance form is defined outside of the main form,
as usual, but also has a "placeholder" attribute set at the same value as the
hidden field (let's say we talk about the Mayors parameter).

When the page is edited with the form, the list of templates set in the Mayors
parameter are taken out of the Town template, and appended at the end of the
data, as if we were in a normal multiple-instance form situation. A hidden
field is inserted in the HTML at the mayors position, set with a special
"@replace_mayors@" value, and a "@insertpoint_mayors@" text is also inserted.
Then all the HTML continues to be generated. Upon coming on the Mayors
templates, these parts are processed by the separate multiple-instance form
defined for this kind of templates, but are not appended to the end of the
current HTML as usual. All the HTML corresponding to these templates is
reinserted at the @insertpoint_mayors@ position, which finally gives the
illusion to have a multiple-instance nested form inside the main form once
everything is displayed.


On form submission, the fields values are translated into medaiwiki templates
as usual, and the Mayors parameter is first set to  "@replace_mayors@" (the
hidden field value), but then the list of templates generated from the
multiple-instance form is reinserted in this position.

I set up a test instance here to see show it works:
http://www.saintseiyapedia.com/wikitest/Main_Page
user/pass: test/testsmf

Issues: 

1.it is only possible to to 1 depth level of nested templates (but possible to
get as many nested templates on the base depth as you want). Putting a
placeholder system in something that is already a placeholder won't work. To do
that, a lot of refactoring into a recursive solution would be needed. I tried
to not touch the overall logic.

Notes:

1. Normal multi-instance forms still work and can even be used at the same time
as placeholder ones. By the way, since this fix tries to not alter too much the
original logic, some code duplication was done at the end of the multi-instance
temaplte part, but a better refactoring woul be to remove the normal
multi-instance logic, and use the placeholder logic instead, since the original
functionality could be easily mimicked by putting a dummy placeholder value at
the end of the currently processed HTML.

2. Most explanations are in the code comments, usually delimited by //addition
and //remove tags

-- 
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to