Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

netteForms.js: passing multiple controls as validator argument #176

Open
MartinSzollos2016 opened this issue Mar 8, 2018 · 3 comments
Open

Comments

@MartinSzollos2016
Copy link

MartinSzollos2016 commented Mar 8, 2018

  • bug report? yes
  • feature request? no
  • version: 2.4

Description

Při použití vlastních valičních pravidel se nepředají hodnoty, ale objekty:
[{"control":"username"},{"control":"first_name"},{"control":"last_name"}]
Toto nastane až při validaci prvku "password_again".

Problém ve funkci, kde se opětovně validuje prvek oproti starší verzi

Nette.expandRuleArgument = function(form, arg) {
		if (arg && arg.control) {
			var control = form.elements.namedItem(arg.control),
				value = {value: Nette.getEffectiveValue(control)};
            Nette.validateControl(control, null, true, value);
			arg = value.value;
		}
		return arg;
	};

Steps To Reproduce

$form->addPassword('password')
         ->setRequired(_('Vyplňte prosím heslo.'))
         ->addRule($form::MIN_LENGTH, _('Heslo musí mít minimálně %s znaků.'), 8)
         ->addRule(UserFormRules::PASSWORD, _('Heslo nesmí obsahovat login, jméno, ani příjmení.'), [$form['username'], $form['first_name'], $form['last_name']]);
    $form->addPassword('password_again')
        ->setRequired(_('Vyplňte prosím heslo znovu pro kontrolu.'))
        ->addRule($form::EQUAL, _('Zadaná hesla se neshodují.'), $form['password']);
Nette.validators.AppLibsUserFormRules_validatePassword = function (elem, arg, value) {
    var value = webalize(value);
    var res = true;
    $.each(arg, function (id, val) {
        if (value.indexOf(webalize(val)) >= 0 && val.trim().length > 0) {
            res = false;
        }
    });
    return res;
};
@dg
Copy link
Member

dg commented Mar 8, 2018

Do you know how to fix it?

@MartinSzollos2016
Copy link
Author

Unfortunately, no. Bug occurs only when debug mode is enabled.

@MartinSzollos2016
Copy link
Author

It's related to this commit. 2aed83fa86e950038a4103ffef8b5d90c7d7428d. Prevent filtering is true so args can't be filter by expandRuleArgument function.

@dg dg changed the title netteForms.js netteForms.js: passing multiple controls as validator argument Apr 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants