Hi,
 
You pass validators in with the elements you provide the element with.
The result is something like this
 
$form->addElement(new Acer_Form_Element_Flex('teachers', 

    array(

        'elements' => array(

            $form->createElement('text', 'name', array('label' =>
'Name', 'class' => 'inputbox', 'size' => 35)),

            $form->createElement('text', 'email', array('label' =>
'Email', 'class' => 'inputbox', 'size' => 35,

                'validators' => array('EmailAddress'))) 

         ),

        'validators' => array(new Acer_Validate_Teachers())

   )

));

 
It's called flex in this case because it creates a flexible table of
rows, there's some javascript in the form decorator (which you can
remove if you wish)
that allows for the adding of new rows. While I do pass in a custom
validator the actual element this doesnt currently display messages
(it's on my todo list).

Populating from the posted form variables works fine as well and i think
it displays errors in a list per row at the moment (a little bit hard
coded i think).
 
Otherwise it seems to be working quite well. I do realise the
implementation isnt wonderful, but if anyone reading this does have any
input on how it could be improved i'd love to hear it.
 
Form Element : http://pastebin.com/m438d1001
<BLOCKED::http://pastebin.com/m438d1001> 
Form Decorator : http://pastebin.com/d840e740
 
Thanks,
Daniel.

________________________________

From: [email protected] [mailto:[email protected]] 
Sent: Monday, 20 April 2009 12:09 PM
To: Fullarton, Daniel; Nabble Zend Framework General
Subject: RE: [fw-general] Multidimensional MultiCheckbox


Daniel,

Thank you for your response. Actually, I would love to see what you have
come up with. I'm curious: does your custom element allow for validation
and/or repopulating selected values for redrawing the form too? That
would be quite a sweet addition which would be of very good use for me
at this moment. :-)

In any case, I'm looking forward to seeing your implementation somewhere
for me to download. Much appreciated. Thank you in advance.




________________________________

Date: Mon, 20 Apr 2009 11:44:50 +1000
From: [email protected]
To: [email protected]; [email protected]
Subject: RE: [fw-general] Multidimensional MultiCheckbox


This would probably require a custom element. I've actually created a
similar element for a project im working on that generates a subform for
each 'row' that contains an number of zend_form_elements passed in to it
via the constructor. 
 
It does however generate the names in the form "media[0]['image']" &
"media[0]['video']" so the data comes out in rows.
 
I have a feeling I read something by matthew where he mentions that zend
forms shouldnt use the numeric array notation, but in this case I sort
of felt it was the best way.
 
Let me know if you wish to see the element and decorator and ill stick
it up in pastebin somewhere.
 
Thanks,
Daniel.

________________________________

From: [email protected] [mailto:[email protected]] 
Sent: Monday, 20 April 2009 7:13 AM
To: Nabble Zend Framework General
Subject: [fw-general] Multidimensional MultiCheckbox


Hi all,

My apologies if you receive this message multiple times. But my messages
don't seem to reach the list anymore. Hopefully through this route it
will. 

My question is this: Is there any way to create a multidimensional
MultiCheckbox which result in something like this:
<input type="checkbox" name="media['image'][0]">
<input type="checkbox" name="media['image'][1]">
<input type="checkbox" name="media['video'][0]">
<input type="checkbox" name="media['video'][1]"> 

etc...?


Thank you in advance.


________________________________

Haal meer uit je Hotmail met Internet Explorer 8. Download nu
<http://www.microsoft.nl/ie8> 

________________________________

Deel je favoriete foto's online met Windows Live Photos
<http://www.microsoft.com/netherlands/windowslive/Views/productDetail.as
px?product=Photos>  

Reply via email to