forms
forms copied to clipboard
TextBase support mixed as value
- bug fix? no
- new feature? yes
- BC break? no
adds support for
// class without __toString method
final class User {
// ..
}
$repo = function(string $userName): ?User {
return new User;
}
$form = new Nette\Forms\Form;
$form->addText('user', 'Username')
->addFilter(function (string $userName) use ($repo) {
return new Nette\Forms\ScalarValue($userName, $repo($userName)));
} )
;
$form->onSuccess[] = function(Nette\Forms\Form $form, array $values): void {
$values['user'] instanceof User || null;
};