power-media / prado3

Automatically exported from code.google.com/p/prado3
Other
0 stars 0 forks source link

Using a TActiveCustomValidator with a TActiveTextBox and AutoPostBack does not work as expected. #428

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Register.page

<com:TForm ID="frmRegister">
  <h1 class="register">Register</h1>
  <fieldset class="register">
    <legend>Register New Account</legend>
    <div class="username">
      <com:TLabel ForControl="username" text="Username:" />
      <com:TActiveTextBox ID="username" MaxLength="50" AutoPostBack="true" ValidationGroup="username" />
      <com:TActiveCustomValidator ControlToValidate="username" OnServerValidate="checkFreeUsername" Display="Dynamic" ValidationGroup="username"
    </div>
  </fieldset>
</com:TForm>

2. Register.php

class Register extends TPage
{
  public function checkFreeUsername($sender, $param)
  {
    $param->IsValid = false;
  }
}

3. Enter text into the field

What is the expected output? What do you see instead?

The error message should appear and stay there, but instead it appears for a 
short time and then disappears.

What version of the product are you using? On what operating system?

prado-3.2.0.r3169 on PHP 5.3.19-1~dotdeb.0 in Chrome.

Please provide any additional information below.

The Java debug shows that the server is setting IsValid to true, and then 
false, which should not be a problem... but for some reason this causes this 
strange behaviour. I have added the following fix which corrects this, but it 
may also warrant a javascript dev looking into why this double message causes 
this strange behaviour.

Add to TActiveCustomValidator.php on line 109:

                if ($value == $this->getIsValid())
                        return;

This prevents sending the additional message when the state has not changed.

Original issue reported on code.google.com by ge...@spacevs.com on 22 Dec 2012 at 3:51

GoogleCodeExporter commented 8 years ago
Just discovered the proposed fix does not correct the problem completely.

Another possible workaround is to comment out TBaseValidator.php line 510, but 
I am not sure as to what repercussions this may cause.

Original comment by ge...@spacevs.com on 22 Dec 2012 at 3:54

GoogleCodeExporter commented 8 years ago
I've tried to use your testcase to check the problem, but i've been unable to 
reproduce it.
Your testcase is missing the "submit" button, i've added a TActiveButton, maybe 
you are using something different?
Can you try this example: 
http://www.pradosoft.com/demos/quickstart/?page=ActiveControls.Samples.TActiveCu
stomValidator.Home and check if it works for you?

Original comment by ctrlal...@gmail.com on 23 Dec 2012 at 8:43

GoogleCodeExporter commented 8 years ago
Hi,

Thanks for looking into this.

The form does have a submit button, but in this instance it is not required as 
the TActiveTextBox has AutoPostBack="true", so when the field is left, the 
ValidationGroup "username" is validated. It works fine with a submit, but not 
when using AutoPostBack.

Original comment by ge...@spacevs.com on 23 Dec 2012 at 10:42

GoogleCodeExporter commented 8 years ago
Turns out this is a duplicate to #394 , previously fixed in r3135. 
Inadvertently the fix got reverted in a big commit (r3159), so the bug 
reappeared.
The fix has been committed again as r3228, thank you for the report!

Original comment by ctrlal...@gmail.com on 28 Dec 2012 at 5:17