0

I see syntax on http://framework.zend.com/manual/en/zend.validate.writing_validators.html

The case- what does %value% mean and doing?

  protected $_messageTemplates = array(
    self::FLOAT => "'%value%' is not a floating point value"
  );

Thanks

Charles
  • 50,943
  • 13
  • 104
  • 142
Ben
  • 25,389
  • 34
  • 109
  • 165
  • Maybe someone could also explain why they are using `%value%` and not just the typical [printf](http://php.net/manual/en/function.sprintf.php) `%s` placeholder. – mario Jan 30 '11 at 11:56

1 Answers1

5

It's a placeholder that will be replaced by the field's value when displaying this error.

If a user enters "ABC" is this field, the error message will be "'ABC' is not a floating point value"

This is like printf's %s placeholders, in a more verbose and easy to use form. Validators can add their own placeholder variables, and it's easier to deal with %value%, %somevar% than with (positional) %1$s, %2$s, particularly for translators.

Arnaud Le Blanc
  • 98,321
  • 23
  • 206
  • 194
  • Thanks!Can you please show where does it happen in zend source code? – Ben Jan 30 '11 at 11:58
  • I find out :in Zend_Validate_Abstract $message = str_replace('%value%', (string) $value, $message); – Ben Jan 30 '11 at 12:01