Huomenta Simon,

looking at the code of AgaviValidator, there seems to be now out-of- 
the-box way to achieve this.
What I did while writing a validator for Redracer was, that I got all  
args via $args = $this->getArguments(), then checked if the key aka  
the argumentname exsists and then got the data via $this- 
 >getData($args['foobar']);

Also as stated in the class ( http://bit.ly/uScYd )the getArgument  
method is to be used by validators which expect only 1 Argument.

Cheers
Benjamin


Am 12.08.2009 um 09:10 schrieb Simon Cornelius P Umacob:

> Huomenta!
>
> I'm encountering the same problem described in the previous post.  I'm
> curious, is AgaviValidator::getArgument('argument_name') still valid
> in the latest Agavi version?  I browsed through
> AgaviValidator.class.php, but the getArgument() method doesn't accept
> any parameters.  How can I get an argument via its name?
>
> Thanks!
>
>
> [ simon.cpu ]
>
> On Mon, Jul 6, 2009 at 10:27 PM, David
> Zülke<[email protected]> wrote:
>> Yes, there is a better way :)
>>
>> Validators support named arguments.
>>
>> Do this in your code:
>>
>> $max = $this->getData($this->getArgument('max'));
>> $min = $this->getData($this->getArgument('min'));
>>
>> And in the XML:
>>
>> <validator class="PriceRangeCustomValidator">
>> <argument name="max">pmax</argument>
>> <argument name="min">pmin</argument>
>> </validator>
>>
>> Cheers,
>>
>> David
>>
>>
>>
>> On 06.07.2009, at 15:00, Simon Cornelius P Umacob wrote:
>>
>>> Hi, I'm a bit tipsy right now. Just correct me in case I suggest a
>>> wrong advice. =)
>>>
>>> $max = $this->getData($this->getParameter('max'));
>>> $min = $this->getData($this->getParameter('min'));
>>>
>>> In your XML file, do:
>>>
>>>              <validator class="PriceRangeCustomValidator">
>>>                              <argument>pmax</argument>
>>>                              <argument>pmin</argument>
>>>                              <ae:parameter name="max">pmax</ 
>>> ae:parameter>
>>>                              <ae:parameter name="min">pmin</ 
>>> ae:parameter>
>>>              </validator>
>>>
>>> Regards,
>>>
>>> [ simon.cpu ]
>>>
>>> On Mon, Jul 6, 2009 at 8:39 PM, <[email protected]>  
>>> wrote:
>>>>
>>>> Hi
>>>>
>>>> I have the following custom validator:
>>>>
>>>> <?php
>>>> class PriceRangeCustomValidator extends AgaviValidator {
>>>>
>>>> protected function validate()
>>>> {
>>>> $max = $this->getData('VehicleSalePriceMax');
>>>> $min = $this->getData('VehicleSalePriceMin');
>>>> if ($min > $max)
>>>> {
>>>>     $this->throwError('max_min_mismatch');
>>>>     return false;
>>>> }
>>>> return true;
>>>> }
>>>>
>>>> }
>>>> ?>
>>>>
>>>> I'd like to reuse this in another form, where the two inputs are  
>>>> named
>>>> pmin and pmax. Is there a way for me to do this - maybe by  
>>>> editing the
>>>> above code to use generic input arguments instead of named form
>>>> inputs?
>>>>
>>>> Thanks
>>>>
>>>> Vikram
>>>>
>>>> _______________________________________________
>>>> users mailing list
>>>> [email protected]
>>>> http://lists.agavi.org/mailman/listinfo/users
>>>>
>>>
>>> _______________________________________________
>>> users mailing list
>>> [email protected]
>>> http://lists.agavi.org/mailman/listinfo/users
>>>
>>
>>
>> _______________________________________________
>> users mailing list
>> [email protected]
>> http://lists.agavi.org/mailman/listinfo/users
>>
>>
>
> _______________________________________________
> users mailing list
> [email protected]
> http://lists.agavi.org/mailman/listinfo/users


_______________________________________________
users mailing list
[email protected]
http://lists.agavi.org/mailman/listinfo/users

Reply via email to