[TYPO3-project-formidable] New Features in renderer template: Set your own errorWrap etc.
Jerome Schneider
typo3dev at ameos.com
Thu Mar 5 10:46:43 CET 2009
Hi Hauke,
I added your code and it will be available in upcoming revision 2.0.325.
I modified a bit the tagnames for errorTagWrapAlways which has become
errorTagCompiledNoWrap, that takes a true to achieve the same as
errorTagWrapAlways with a false.
So the available properties are:
errorTagWrap
errorTagCompiledNoWrap
errorTagCompiledNoBr
Thanks for your work !
Jerome
Hauke Hain a écrit :
> Hello,
>
> template/errorTag as described here:
> http://formidable.typo3.ug/reference/control/renderertemplate.html
>
> Your errortag ({myerrortag.mytxt1.tag}) will be wrapped with
> <span class="errors">{myerrortag.mytxt1}</span>
>
>
> I changed the template renderer so that you can choose how it should be
> wrapped.
>
> On top of that you can say that each errormessage gets wrapped even if
> you dosplay all at once with this code:
> <div style="display: {myerrortag.cssdisplay};">
> {myerrortag} <!-- each error is wraped with the standard tag or your
> setting -->
> </div>
>
> This can be useful if you want to have your errormessages in a list.
>
> So you can use this
> <ul style="display: {myerrortag.cssdisplay};">
> <li style="display:
> {myerrortag.renderlet1.cssdisplay};">{myerrortag.renderlet1}</li>
> <li style="display:
> {myerrortag.renderlet2.cssdisplay};">{myerrortag.renderlet2}</li>
> <li style="display:
> {myerrortag.renderlet3.cssdisplay};">{myerrortag.renderlet2}</li>
> </ul>
>
> or this code
> <ul style="display: {myerrortag.cssdisplay};">
> {myerrortag} <!-- each error is wraped with the standard tag or your
> setting -->
> </ul>
>
> and this XML-Configuration:
> <renderer:TEMPLATE>
> <template
> path=""
> subpart=""
> errorTag=""
> errorTagWrapAlways="True"
> errorTagCompiledNoBR="True">
> <errorTagWrap><![CDATA[<span>]]>|<![CDATA[</span>]]></errorTagWrap>
> </template>
> </renderer:TEMPLATE>
>
> in order to get your errormessages in an unordered list.
>
>
> As you can see I added one more configuration: errorTagCompiledNoBR="True"
> If set, the compiled errormessages (all messages as one string) are not
> separated by a <br/>-Tag.
> This is handy if you set a wrap that makes the br-Tag redundant or in
> worst case it makes your webpage invalid.
>
>
> My Solution:
> ameos_formidable\api\base\rdr_template\api\class.tx_rdrtemplate.php
> I replaced row 133 to 140.
> REPLACE:
> $aCompiledErrors[] = $this->oForm->_aValidationErrors[$sRdtName];
> $aErrors[$sShortRdtName] = $this->oForm->_aValidationErrors[$sRdtName];
> $aErrors[$sShortRdtName . "."]["tag"] = "<span class='errors'>" .
> $this->oForm->_aValidationErrors[$sRdtName] . "</span>";
> }
> }
>
>
> $aErrors["__compiled"] = implode("<br />", $aCompiledErrors);
>
>
> WITH:
> $aErrors[$sShortRdtName] =
> $this->oForm->_aValidationErrors[$sRdtName];debug($this->_navConf);
> if(($errWrap = $this->_navConf("/template/errortagwrap")) !== FALSE) {
>
> if($this->oForm->isRunneable($errWrap)) {
> $errWrap = $this->callRunneable($errWrap);
> }
>
> $errWrap = $this->oForm->_substLLLInHtml($errWrap);
> } else {
> $errWrap = "<span class='errors'>|</span>";
> }
> $aErrors[$sShortRdtName . "."]["tag"] = str_replace("|",
> $this->oForm->_aValidationErrors[$sRdtName], $errWrap);
>
> if(strtolower(trim($this->_navConf("/template/errortagwrapalways"))) ==
> "true") {
> $aCompiledErrors[] = str_replace("|",
> $this->oForm->_aValidationErrors[$sRdtName], $errWrap);
> } else {
> $aCompiledErrors[] = $this->oForm->_aValidationErrors[$sRdtName];
> }
> }
> }
>
>
> if(strtolower(trim($this->_navConf("/template/errortagcompilednobr")))
> == "true") {
> $aErrors["__compiled"] = array();
> $aErrors["__compiled"] = implode($aCompiledErrors);
> } else {
> $aErrors["__compiled"] = implode("<br />", $aCompiledErrors);
> }
>
>
> I added my new file. I hope this is something that can be applied to the
> svn-version.
>
>
> Pleaso note that tjis works only with the renderer template. You have to
> make equally changes to the other renderlets, if you want the same
> functionality.
>
> Perhaps the STANDARD renderer is interesting. Here you have to adjust
> the following lines:
>
> You have to change
> ameos_formidable\api\base\rdr_std\api\class.tx_rdrstd.php in line 18-20:
> if(!$this->oForm->oDataHandler->_allIsValid()) {
> $sValidationErrors = "<div class='errors'><div class='error'>" .
> implode("</div><div class='error'>",
> $this->oForm->_aValidationErrorsByHtmlId) . "</div></div><hr
> class='separator' />";
> }
>
>
> Regards,
> Hauke
More information about the TYPO3-project-formidable
mailing list