You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, i have a login form with email and password elements. I need to clear the password value when validation fails.
In my /Phalcon/Forms/Form i have this:
$email = newText('email', [
'placeholder' => DI::getDefault()->get("translation")->query("Insert your Email")
]);
$email->addValidators( [
newPresenceOf( [
'message' => DI::getDefault()->get("translation")->query("The field is required"),
'cancelOnFail' => true
]),
newEmail( [
'message' => DI::getDefault()->get("translation")->query("Invalid email address")
])
]);
$password = newPassword('password', [
'placeholder' => DI::getDefault()->get("translation")->query("Insert your Password")
]);
$password->addValidators([
newPresenceOf( [
'message' => DI::getDefault()->get("translation")->query("The field is required"),
'cancelOnFail' => true
]),
newStringLength([
'min' => 7,
'messageMinimum' => DI::getDefault()->get("translation")->query("The text is too short")
])
]);
$password->setDefault("");
$password->clear();
$this->add($email);
$this->add($password);
in my view i have a simple render for both, and after the post i check the value with the isValid() function.
The problem is that when i have a validation error the password won't reset.
The problem is that when using isValid() which calls the bind() function,.
The bind() set automatically all post parameters into _data (a protected variable of the form) let this->_data = data;
and this clear function never change the parameters inserted into this variable.
publicfunctionclear(var fields = null) -><Form>
{
var elements, element;
let elements =this->_elements;
iftypeof elements =="array" {
for element in elements {
iftypeof fields !="array" {
element->clear();
} else {
if in_array(element->getName(), fields) {
element->clear();
}
}
}
}
returnthis;
}
Hi, i have a login form with email and password elements. I need to clear the password value when validation fails.
In my /Phalcon/Forms/Form i have this:
in my view i have a simple render for both, and after the post i check the value with the isValid() function.
The problem is that when i have a validation error the password won't reset.
I try this for debugging:
but none of those reset my value on the form.
The problem is that when using isValid() which calls the bind() function,.
The bind() set automatically all post parameters into _data (a protected variable of the form)
let this->_data = data;
and this clear function never change the parameters inserted into this variable.
My solution
The text was updated successfully, but these errors were encountered: