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 theabove 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
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ users mailing list [email protected] http://lists.agavi.org/mailman/listinfo/users
