Jump to content

Topic on Extension talk:FlexForm

Create multiple pages with the same template

7
Paul LEMPERIERE (talkcontribs)

I'd like to create two pages using the same template. There are two fields : "Prenom" and "Nom". Each page must have differents values for them.


Something like that :


<_form action="get" >

<_create mwwrite="PERS-1" mwtemplate="Personne" mwfields="Nom, Prenom" />

<_input type="text" name="Nom" />

<_input type="text" name="Prenom" />

<_create mwwrite="PERS-2" mwtemplate="Personne" mwfields="Nom, Prenom" />

<_input type="text" name="Nom" />

<_input type="text" name="Prenom" />

<_input type="submit" value="submit" />

</_form>


If I use the same name for my inputs, it's impossible for FlexForm to know which one goes in which page.

And if I use a different name, for exemple "Nom2" and "Prenom2" for the second page, this will not fit with the fileds of my template.


Is there a way to solve this problem ? Maybe with the parsepost parameter ?


Thanks !

Sen-Sai (talkcontribs)

hi Paul!

First off, an HTML Form cannot have inputs with the same name. Actually it can, but only the last input element in a Form will actually be submitted. This is default HTML behavior.

That doesn't solve your issue, but just so you know.

The _edit function does have the functionality to assign a different name to an input field, but _create does not.

I do find it to be a useful addition, so I will add it to the next release of FlexForm. I'll post an update here when it is done.

Paul LEMPERIERE (talkcontribs)

Thank you a lot !

Sen-Sai (talkcontribs)

No problem. I've added this to version 1.1.19. It is not released as yet as I always want another pair of eyes looking at code before it is released. But I guess it will be available tomorrow. Documentation is already updated.

mwfields = comma separated names of form elements that need to be included. Only works when using multiple _create.

If you are creating multiple pages and want to re-assign form fields to template variables, you still add the form field name to mwfields, but add "::" and then the name of the template variable. So if you want to tell mwfields to use formfield "name2", but add it to the template as "Name", add : "name2::Name" to mwfields.

Sen-Sai (talkcontribs)
Sen-Sai (talkcontribs)

<_form action="get" >

<_create mwwrite="PERS-1" mwtemplate="Personne" mwfields="Nom, Prenom" />

<_create mwwrite="PERS-2" mwtemplate="Personne" mwfields="Nom2::Nom, Prenom2::Prenom" />

<_input type="text" name="Nom" />

<_input type="text" name="Prenom" />

<_input type="text" name="Nom2" />

<_input type="text" name="Prenom2" />

<_input type="submit" value="submit" />

</_form>

That would be the code to use in v1.1.19

Paul LEMPERIERE (talkcontribs)

Hello,

sorry for the late reply, I didn't expect such a quick update !

I'll try tomorrow and I'll keep you informed.

Reply to "Create multiple pages with the same template"