Re: Re: setting Flexy form error messages
| From: | Demian Turner | Date: | Mon, 01 Dec 2003 17:09:56 +0000 |
| Subject: | Re: Re: setting Flexy form error messages | ||
| References: | 1 2 3 4 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-9248@lists.php.net to get a copy of this message | ||
hi alan
This kind of made precompiling templates rather messy. (but I still may consider it..)could be quite handy, currently the flexy parser is quite strict, simply missing an attribute quote dumps largish errors. i understand the parser needs to work according to a strict logic, but if i give templates for example to non-developers i think they would struggle.
Assuming the HTML is <input type="checkbox" name="xxxx" value="3"> $input->flexyElements['xxx'] = new HTML_Template_Flexy_Element; $input->flexyElements['xxx']->value=3; should be enough.. OR <input type="checkbox" name="xxxx[]" value="1"> <input type="checkbox" name="xxxx[]" value="2"> <input type="checkbox" name="xxxx[]" value="3"> <input type="checkbox" name="xxxx[]" value="4"> $elements = new HTML_Template_Flexy_Factory::fromArray( array('xxxx' => array(1,3,4));I would use this approach but the fact that the following is true: <FORM name="XXXX">
<INPUT name="yyy">which compiles to: <?php echo $this->elements['XXXX']->toHtmlnoClose();?>
<?php echo $this->elements['yyy']->toHtml();?>and not <?php echo $this->elements['XXXX']->toHtmlnoClose();?>
<?php echo $this->elements['XXXX']['yyy']->toHtml();?>i think it could quite quickly run into problems. for flexbility i've found it quite convenient to put all form elements into a single array <input type="text" name="user[name]">name <input type="text" name="user[password]">password then cast it to and object from once posted. have just hacked line by line error-reporting which seems easier: <tr>
<td><span style="color: red">*</span><b>Address 1</b></td>
<td >
{if:array_key_exists(#addr_1#,error)}
<div style="color:red">{error[addr_1]}</div>
{end:}
<input name="user[addr_1]" type="text" value="{user.addr_1}" />
</td>
</tr>
with the error messages being set in the model's validation method. make sense?
cheers
demian
Regards Alan