I've added the bits. With the call, how do I create the $context variable?
Michel Morelli wrote:
>
> Waigani ha scritto:
>> I'm testing with '1' as the input value for startPage. While debugging I
>> found that $context was not set, not even an empty array. What an I
>> missing?
>>
>
> In italy we say "Tu sbagli candeggio" (for people +30 years old).
>
> How do you call this Validator ?
> You need to set $context in the __construct() method.
>
> try this:
>
> class My_Validator_PageNo extends Zend_Validate_Abstract
> {
> const NO_END = 'noEnd';
> const NO_START = 'noStart';
>
> private $_context;
>
> protected $_messageTemplates = array(
> self::NO_END => 'A start page has been entered, you must specify
> an
> end page',
> self::NO_START => 'An end page has been entered, you must
> specify a start
> page'
> );
>
> function __construct($context = null) {
> $this->_context = $context;
> }
>
> public function isValid($value)
> {
>
> $value = (string) $value;
> $this->_setValue($value);
>
> if (!empty($this->_context['startPage'])
> && empty($this->_context['endPage']))
> {
> $this->_error(self::NO_END);
> return false;
> }
> else if (! empty($this->_context['endPage'])
> && empty($this->_context['startPage']))
> {
> $this->_error(self::NO_START);
> return false;
> }
>
>
> return true;
> }
> }
>
> And call in this way : ->addValidator(new My_Validator_PageNo($context));
>
> And I see that in your Validator you use only $context and not $value so
> why this ? Can you send the code where you set the Validator ?
>
> And sorry for my bad english.
>
> M.
>
> --
> Michel 'ZioBudda' Morelli [EMAIL PROTECTED]
> Consulenza sistemistica in ambito OpenSource.
> Sviluppo applicazioni web dinamiche (LAMP+Ajax)
> Telefono: 0200619074
> Telefono Cell: +39-3939890025 -- Fax: +39-0291390660
>
> http://www.ziobudda.net ICQ: 58351764
> http://www.ziobuddalabs.it Skype: zio_budda
> http://www.ajaxblog.it MSN: [EMAIL PROTECTED]
>
> JABBER: [EMAIL PROTECTED]
>
>
>
--
View this message in context:
http://www.nabble.com/Does-form-validator-implicitly-set-setRequired%28%29-to-true--tp19265120p19280136.html
Sent from the Zend Framework mailing list archive at Nabble.com.