Re: [PEAR] QuickForm2 catch errors
[email protected] (Mark Steudel)
| Newsgroups | php.pear.general |
|---|---|
| Message-ID | <CAA7FHS1csji1AwXyAwix19iFhjeiRn_JEwawhRwHT643Fw_qew@mail.gmail.com> |
Here's the essential snippet from the docs file:
$renderer = HTML_QuickForm2_Renderer::factory('default')
->setOption(array(
'group_hiddens' => true,
'group_errors' => true,
'required_note' => '<strong>Note:</strong> Required fields are
marked with an asterisk (<em>*</em>).'
))
->setTemplateForId('submit', '<div class="element">{element} or <a
href="/">Cancel</a></div>')
->setTemplateForClass(
'HTML_QuickForm2_Element_Input',
'<div class="element<qf:error>
error</qf:error>"><qf:error>{error}</qf:error>' .
'<label for="{id}" class="qf-label<qf:required>
required</qf:required>">{label}</label>' .
'{element}' .
'<qf:label_2><div class="qf-label-1">{label_2}</div></qf:label_2></div>'
);
echo $form->render($renderer);
?>
If you look at the setTemplateForClass method, you can see the error html:
<div class="element<qf:error> error</qf:error>"><qf:error>{error}</qf:error>
So all you have to do is move the html around however you like.
MS
On Fri, Feb 1, 2013 at 8:37 AM, Adam Tong <[email protected]> wrote:
> Hi,
>
> You are right. The documentation is not very detailed.
>
> I looked at the source code (Did not find a clear example in the
> docs). If I understand well, the solution would be to create a file
> similar to renderer/default.php and define a class like this
> HTML_QuickForm2_Renderer_MyRenderer extends HTML_QuickForm2_Renderer ...
>
> Is this correct?
>
> On Thu, Jan 31, 2013 at 2:19 PM, Mark Steudel <[email protected]> wrote:
>> Take a look at the renderers. Either check out the docs:
>> http://pear.php.net/manual/en/package.html.html-quickform2.renderers.php
>>
>> Or (and I think easier to quickly understand) check out the examples
>> included in the docs on your pear installation. (e..g on my machine,
>> it's PEAR INSTALL DIR/ doc/Html_QuickForm2
>>
>> Let us know if that doesn't help or if you have questions.
>>
>> MS
>>
>> On Wed, Jan 30, 2013 at 3:32 PM, Adam Tong <[email protected]> wrote:
>>> Hi,
>>>
>>> Is there a way to catch the validation errors of QuickForm2.
>>>
>>> I want to display validation error messages below the fields, instead
>>> of on top of them.
>>>
>>> How can I do that?
>>>
>>> Thank you
>>>
>>> --
>>> PEAR General Mailing List (http://pear.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>
>>
>>
>> --
>> -----------------------------------------
>> Mark Steudel
>> P: 425.298.7244
>> F: 206.260.3021
>> [email protected]
>>
>> . : Adoption Updates : .
>> http://www.steudel.org/blog
>>
>> . : Work : .
>> http://www.mindfulinteractive.com
>>
>> . : LinkedIn : .
>> http://www.linkedin.com/in/steudel
--
-----------------------------------------
Mark Steudel
P: 425.298.7244
F: 206.260.3021
[email protected]
. : Adoption Updates : .
http://www.steudel.org/blog
. : Work : .
http://www.mindfulinteractive.com
. : LinkedIn : .
http://www.linkedin.com/in/steudel