properties - Typo3 Unsupported validation option(s) found -


im working on example typo3 extension book, , i‘m @ part create own validators. in controller placed following:

/** * title of blog * * @var string * @validate notempty, \lobacher\simpleblog\validation\validator\wordvalidator(max=3) */ protected $title = ''; 

in file simpleblog\validation\validator\wordvalidator.php code:

<?php namespace lobacher\simpleblog\validation\validator;  class wordvalidator extends \typo3\cms\extbase\validation\validator\abstractvalidator {     public function isvalid($property) {         $max = $this->options['max'];          if (str_word_count($property, 0) <= $max)         {             return true;         }         else         {             $this->adderror('verringern sie die anzahl der worte - es sind maximal '. $max .' erlaubt!', 1383400016);             return false;         }     } } ?> 

but if try edit entry typo3 says: unsupported validation option(s) found: max

what did wrong?

you have add protected member $supportedoptions defines allowed parameters of validator.

this member has associative array, option names keys, , option configuration values. option configurations numerically indexed arrays, array entries have following meanings:

  • index 0: default value option (mixed)
  • index 1: description of option (string)
  • index 2: type of option (string, values "string", "integer" etc.)
  • index 3: whether option required (boolean, optional).

an example numberrangevalidator, not using fourth option:

protected $supportedoptions = array(     'minimum' => array(0, 'the minimum value accept', 'integer'),     'maximum' => array(php_int_max, 'the maximum value accept', 'integer'),     'startrange' => array(0, 'the minimum value accept', 'integer'),     'endrange' => array(php_int_max, 'the maximum value accept', 'integer') ); 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -