Am 14.08.15 um 12:18 schrieb Viktor Livakivskyi:
Hi, Bernd.

Thank you for your answer.

3. you can call each section within a partial individually
Yes, and no =) I can call only section of this or other partial from
within a partial. But I can't call a section of a template from a
partial. Or I just didn't find, how I can do this.

yes

   < f:render partial="inputfields.html" section="input"
arguments="{fieldname:'surname',label:'Surname',required:1,errtxt:'enter
your surname',data:user.surname}" />
And that's what I'm, trying  to avoid, because with every new
individualization there will be more and more parameters or possible
values of parameters, like "isStaticInfoZone: 1,
staticInfoCountrySelectorId: 'siCountry', preSelected: 'DE', etc..."

that is a question what you can put into one parameter.
if you have a HTML-block before each input-tag you may render it inside the input-section or render it outside (individually) and drop the complete HTML into the input section. you also may provide individual parameters to each attribute or pass all the attributes (and values) in one string:

<section name="input">
<input class="{class}" id="{id}" onChange="{onChange}" value="{value}" ... /></section>

<section name="input2">
<input {attributes} />
</section>

<f:render section="input" arguments="{class:'wide',id:{fieldname},onChange:'alert(\'wow\');',value:10}" />

<f:render sectio="input2" arguments="{attributes:'class=\"wide\" id=\"{fieldname}\" onChange=\"alert(\'wow\');\" value=\"10\"'}" /> <f:render sectio="input2" arguments="{attributes:'class=\"narrow\" id=\"{fieldname2}\"'}" />


Currently I'm doing it almost as you proposed:
RegistrationForm.html
<f:render partial="Field" section="Main" arguments="{field: 'city',
type: 'Textfield'}" />
<f:render partial="Field" section="Main" arguments="{field:
'staticInfoCountry', type: 'SelectCountry', selected:
'{user.staticInfoCountry}'}" />

Field.html
<f:section name="Main">
---all the common stuff comes here---
<f:render section="{type}" arguments="{field: '{field}', values:
'{values}', selected: '{selected}'}" />
</f:section>

<f:section name="Textfield">
     <f:form.textfield property="{field}" class="form__field
form__field_input" id="field-{field}" />
</f:section>

<f:section name="SelectCountry">
     <f:if condition="{selected}">
         <f:then>
             <register:form.SelectStaticCountries property="{field}"
id="sfrCountry" value="{selected}" optionLabelField="cnShortEn"
class="form__field form__field_select" />
         </f:then>
         <f:else>
             <register:form.SelectStaticCountries property="{field}"
id="sfrCountry" value="DE" optionLabelField="cnShortEn"
class="form__field form__field_select" />
         </f:else>
     </f:if>
</f:section>

...

I might change it a little bit:
call the section directly
<f:render partial="Field" section="Textfield" arguments="{field:'city'}" />

and inside that section make a common call to globals:

<f:section name="Textfield">
  <f:render section="globalStuff" arguments="{_all}" />
<f:form.textfield property="{field}" class="form__field form__field_input" id="field-{field}" />
</f:section>

so the calls will get a little bit slimmer


So, for each field I either create a special section in partial or add
some parameter. But I still don't like this solution, because it forces
me to hold specific form adjustments not inside the form template
itself, but in partial (or other partials).
In other words: if I want to reuse same partial for other forms with
same field layout but their specific adjustments, I'll have to either
invent more parameters to pass to Field partial or create more sections.
And these specific parameters or sections will be used only once.

for all output you have to define some HTML, and so you may use it only once it has to be defined. you just can consider where you want that unique definition: in your main-template or in a section inside a partial. the whole art about is to identify the common parts and the individual parts and decide what all those individual parts have in common. :)

bernd
--
http://www.pi-phi.de/cheatsheet.html
_______________________________________________
TYPO3-english mailing list
TYPO3-english@lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english

Reply via email to