Re: QuickForm ITStatic Renderer and Error Handling
| From: | Jeff Schmidt | Date: | Mon, 17 May 2004 15:44:41 +0000 |
| Subject: | Re: QuickForm ITStatic Renderer and Error Handling | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-12541@lists.php.net to get a copy of this message | ||
Bertrand Mansion wrote:
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
Jeff Schmidt wrote:Ok, it is working. The reason I didn't try it first is that I just kinda made up myform_error_block hoping that you guys supported some kind of outer block like that. I guess maybe I don't exactly understand ITStatic templating either. . . by which I mean, is the reason the above works because you guys explicitly tell the ITStatic renderer to render a block called $formname . "_error_block" and then render $formname . "_error_loop" inside it in the ITStatic renderer code? Or is this just a case where, I defined the outside block, then tell the renderer to remove empty blocks (i.e. blocks where no variables get subtituted) and then in your renderer code, you simply tell the renderer to substitute variable in a loop called $formname . "_error_loop"? Or more simply, does the IT Template Engine simply render my block based upon whether it is empty or not? Put another way, could I have called my outer block anything at all, and it would still work, because IT simply checks to see whether any variable substitution occured to decide whether or not to render the block? Jeff SchmidtHello, I've been developing a QuickForm with ITStatic renderer and some templates I created. In the introduction to the IIStatic Renderer, I found the following: -- begin quote -- If you prefer to have all your errors displayed at the same place, pass an empty string to setErrorTemplate() and add this block to your template at the position you want: <!-- BEGIN myform_error_loop --> <font color="red">{myform_error}</font><br /> <!-- END myform_error_loop --> --end quote-- Here's my question: Is it possible to have content *outside* the loop, that gets rendered only if there are errors that get rendered *inside* the loop? To whit, what I want to do is, if I have Errors to display, I'd like to output a pair of div tags (that is, open/close) and a pair of ul tags (again open/close), and a message "The following errors were encountered on this form:" More concrete example: <!-- BEGIN myform_error_block --> <!--is there actually something like this?--? <div style="text-align: center; width: 100%"> <!-- outer div exists because MSIE is broken and doesn't correctly implement margin-{left/right}: auto --> <div style="border: thin solid red; width: 50%; margin-left:auto; margin-right:auto; color: red;"> <h2>The following errors were encountered on this form:</h2> <ul> <!-- BEGIN myform_error_loop --> <li>{myform_error}</li> <!-- END myform_error_loop --> </ul> </div> </div> <!-- END myform_error_block --> This would result in something that would look like: ------------------------------------------------------- | The following errors were encountered on this form: |This should work. Did you try it ? I think it is handled by the remove unknown blocks option in IT/Sigma renderers. BTW, remove useless comments like <!-- outer div exists because MSIE is broken and doesn't correctly implement margin-{left/right}: auto --> from your templates, it just wastes bandwidth and might confuse the regex parser. Bertrand Mansion Mamasam| | | * Error1 | | * Error2 |-------------------------------------------------------
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc