Hallo,
ich habe folgendes Problem.
Ich nutze in FormEdit (formularblock, Absatzvorlage) folgenden Code um eine Validierung der Pflichtfelder zu erstellen.
st_formularblock:
$-- For mandatory fields: Hint for Preview only --$
$CMS_IF(#global.preview)$
$CMS_RENDER(template:"ft_preview_mandatory_fieldsv", list: ["st_button_submit", "st_actionlist"], sectionElement: #global.section)$
$CMS_END_IF$
Die Pflichtfelder werden als String-Array an die Variable list übergeben. Diese wird dann im angegebenen Template weiterverarbeitet.
ft_preview_mandatory_fields:
$CMS_IF(#global.preview)$
$CMS_SET(setFieldsWarnings,"")$
$CMS_SET(langLabel,"")$
$CMS_SET(setFieldsWarnings)$$CMS_TRIM(level:4)$
$--CMS_VALUE(list.toString())--$
$CMS_FOR(item, list)$$--
--$$-- field exits --$$--
--$$CMS_VALUE((sectionElement.getFormData().form.findEditor(item)!=null))$$CMS_IF(sectionElement.getFormData().form.findEditor(item)!=null)$$--
--$$-- field value is empty --$$--
--$$CMS_IF(sectionElement.getFormData().get(#global.language, item).isEmpty())$$--
--$$CMS_FOR(langInfo, sectionElement.getFormData().form.findEditor(item).langInfos)$$--
--$$CMS_IF(langInfo.getLang().equals(#global.language.abbreviation))$$--
--$$CMS_SET(langLabel,langInfo.getLabel())$$--
--$$CMS_ELSIF(langInfo.getLang().equals("*"))$$--
--$$CMS_SET(langLabel,langInfo.getLabel())$$--
--$$CMS_END_IF$$--
--$$CMS_END_FOR$$--
--$$CMS_IF(!langLabel.isEmpty())$$--
--$$CMS_VALUE("<li>"+langLabel.replaceAll("[:|*]","")+"</li>")$$--
--$$CMS_END_IF$$--
--$$CMS_END_IF$$--
--$$CMS_END_IF$
$CMS_END_FOR$
$CMS_END_TRIM$$CMS_END_SET$
$CMS_IF(!setFieldsWarnings.isEmpty())$
<div class="cntBox $CMS_VALUE(setWidth,default:"col4")$">
<div style="color:#D00101; border:1px solid red; padding:10px;font-size:0.9em;">
<h2 style="color:red;">$CMS_VALUE(psTransWarningMandatory,default:"Warning")$ ($CMS_VALUE(sectionElement.getDisplayName(#global.language))$)</h2>
<p>$CMS_VALUE(psTransFormHintMandatory,default:"Please fill in all fields marked with an asterisk (<span>*</span>)!")$</p>
<ul style="margin:0px;">$CMS_VALUE(setFieldsWarnings)$</ul>
</div>
</div>
$CMS_END_IF$
$CMS_END_IF$
Das Problem ist nun, dass wenn ich innerhalb des Absatztemplates eine FS_LIST habe, und in dieser ein anderes Absatztemplate einbinde, #global.section nicht mehr funktioniert, bzw immer auf das Hauptabsatztemplate verweist (st_formularblock).
Beispielaufruf in st_formcomboboxdate:
$-- For mandatory fields: Hint for Preview only --$
$CMS_IF(#global.preview)$
$CMS_RENDER(template:"ft_preview_mandatory_fields__rb_dev", list: ["st_startDate", "st_endDate", "form_label"], sectionElement: #global.section)$
$CMS_END_IF$
Die Frage ist nun, was ich statt "#global.section" (sectionElement) in meinen Absatztemplates für die FS_LIST angeben muss, damit auch die Stringvariable übergeben wird und die richtigen Daten verarbeitet werden.
Hoffe ich konnte es einigermaßen verständlich erklären.