Hello Hector,
I already removed the validator by one of the date fields.
Now the problem is on how to compare the dates. I created date objects from
all the date fields within the validator. But I don't know how to do the
last part (i.e comparing the dates.) I converted the field values to
zend_date objects. But when I print the date object to the screen i get:
array(1) { [0]=> object(Zend_Date)#109 (8) { ["_locale:private"]=> string(5)
"en_US" ["_fractional:private"]=> int(0) ["_precision:private"]=> int(3)
["_unixTimestamp:private"]=> string(10) "1262127600" ["_timezone:private"]=>
string(16) "Europe/Amsterdam" ["_offset:private"]=> int(-3600)
["_syncronised:private"]=> int(0) ["_dst:protected"]=> bool(true) } }
See here the updated code:
http://pastebin.com/m6cb13d9d
On Wed, Dec 30, 2009 at 6:19 PM, Hector Virgen <[email protected]> wrote:
> It looks like you're adding the custom compareDates validator to both date
> elements. It might be easier to just put it in one.
>
> If you can determine that $a < $b, then you already know that $b > $a.
>
> Also, in the $evtStartDate element, you are setting the field to compare to
> $evtEndDate, which hasn't been created yet. Instead of passing in the
> element, try passing in the element's field name "evt_enddate" (as a
> string).
>
> I hope this helps.
>
> --
> Hector
>
>
>
> On Wed, Dec 30, 2009 at 5:16 AM, Jigal sanders <[email protected]>wrote:
>
>> Hello everyone,
>>
>>
>> I have a form with two date fields. One startdate and one enddate. I want
>> to make sure, the end date is not before the startdate.
>> I am trying to create my own validator. Now i based my validator on this
>> tutorial:
>> http://cogo.wordpress.com/2008/04/16/custom-validators-for-zend_form_element/
>> Here is my code: http://pastebin.com/f20aafd32 it's not yet ready.
>> My problem is at line 52 where the value of $this->_fieldsToCompare is
>> empty all the time.
>> I also have problems in comparing the dates.
>>
>> Kan someone please help me along?
>>
>>
>> <http://cogo.wordpress.com/2008/04/16/custom-validators-for-zend_form_element/>
>>
>> Kind regards,
>>
>> J. Sanders
>>
>
>
--
Met vriendelijke groet,
Jigal Sanders
A.J. Ernststraat 739
1082 LK Amsterdam
Mobiel: 06-42111489