Hi Jeremy,
you can either write your own validator to do this or use some depends/
provides magic. There's a short discussion in this thread:
http://groups.google.com/group/agavi-users/browse_thread/thread/abcfb892728aa391#
- basically you'd have a validator that provides a base and separate
validators that validate each item in the array:
<validator class="isset" provides="room">
<base>enquiry[rooms][]</base>
</validator>
<validator class="number" depends="[room]">
<argument>no_adults</argument>
</validator>
<validator class="number" depends="[room]">
<argument>no_children</argument>
</validator>
This is from the top of my head, you might need to fiddle around with
the base values but in general this should work. Mind the angled
brackets around the [depends], they are important.
felix
On Oct 15, 2009, at 1:49 AM, Jeramy Wenserit wrote:
> Hi,
>
> I've been attempting to implemented a 3D array as outline in the
> following HTML example:
>
> <input type="text" name="enquiry[rooms][0][no_adults]" value="2"
> id="rooms_0_no_adults" /><br />
> <input type="text" name="enquiry[rooms][0][no_children]" value="0"
> id="rooms_0_no_children" /><br />
>
> Now firstly i checked to see if I could use the ISSET validator
> class as outlined here:
>
> <validator class="isset" required="true">
> <argument>enquiry[rooms]</argument>
> <error>No rooms specifications defined.</error>
> </validator>
>
> From that validation I personally would of expected this result from
> the validator upon my request:
>
> Enquiry => array(
> ..., //other data
> Rooms => array(
> 0 => array( no_adults => 2, no_children => 0 )
> )
> );
>
> How ever, it appears that Agavi only returns:
>
> Enquiry => array(
> ..., //other data
> Rooms => array(
> 0 => array()
> )
> );
>
> So, as you can see the no_adults and no_children have been omitted,
> so I thought maybe I should attempt to create my own validator to
> see if the data I want is returned from:
>
> $this->getData($this->getArgument());
>
> Which it does, now my i've told the Validator::validate() to return
> a result of true to say that my enquiry[rooms] array is valid, but
> Agavi still is omitting the 2 children attributes. So I'm a little
> stuck to how I can correctly validate this, I can't validate enquiry
> [rooms][0] as it may have more then one room and all following array
> locations wouldn't be tested.
>
> So, my question is, is it possible to return the whole 3D array or
> is there a problem?
>
> Cheers,
>
> Jeramy Wenserit (E_mE)
> e: [email protected]
> w: www.xylesoft.co.uk
>
> _______________________________________________
> users mailing list
> [email protected]
> http://lists.agavi.org/mailman/listinfo/users
--
Felix Gilcher
Bitextender GmbH
Paul-Heyse-Str. 6
D-80336 München
T: +49 89 57 08 15 16
F: +49 89 57 08 15 17
M: +49 172 840 88 28
[email protected]
http://www.bitextender.com/
Amtsgericht München, HRB 174280
Geschäftsführer: David Zülke, Florian Clever
_______________________________________________
users mailing list
[email protected]
http://lists.agavi.org/mailman/listinfo/users