How to add string int fields form messages

Notice: This thread is very old.
leonardoap
Member | 17
+
0
-

Hi i dont know how to add string into error messages field, with numbers %d works fine but i was trying with strings but it does not work with %s or something i do bad

$this->form->addText('email', 'Email')
     ->setRequired('Email field is required')
     ->addRule(Form::MAX_LENGTH, 'The max length allowed is %d',200)
     ->addRule(Form::EMAIL, 'Please write a valid email address')
     ->addRule(callback($this,'isValueTaken'), 'The email %s already exists','email');

the max length works with %d but with the last line it does not show the email that was input on the form (example@dot.com)

i want

The email example@dot.com already exists

but just show

The email already exists
Jan Tvrdík
Nette guru | 2595
+
+1
-

Use %value instead of %s, i.e.

->addRule(callback($this, 'isValueTaken'), 'The email %value already exists', 'email');

Last edited by Jan Tvrdík (2015-02-09 20:25)