pradosoft / prado

Prado - Component Framework for PHP
Other
186 stars 70 forks source link

TActiveCustomValidator CallBack problem #104

Closed ctrlaltca closed 11 years ago

ctrlaltca commented 11 years ago

From gacev...@gmail.com on January 22, 2009 17:30:30

What steps will reproduce the problem? 1. Create a page with a TTextbox and TActiveCusctomValidator for it. Of course you will need a TButton also.

  1. Type a valid word (you must do the logic) and click the submit button.
  2. You will need to click once again in order to submit the form. What is the expected output? What do you see instead? If the form is valid, it should be submitted without need of clicking twice. What version of the product are you using? On what operating system? PRADO 3.1.4, Ubuntu 8.10 Please provide any additional information below. Browser: Mozilla Firefox 3.0.5 Web server: lighttpd 1.4.18

Original issue: http://code.google.com/p/prado3/issues/detail?id=103

ctrlaltca commented 11 years ago

From Christophe.Boulain@gmail.com on May 29, 2009 04:54:42

Labels: -Milestone-3.1.5 Milestone-3.1.6

ctrlaltca commented 11 years ago

From Christophe.Boulain@gmail.com on July 22, 2009 01:15:51

Move to 3.1.7

Labels: Milestone-3.1.7

ctrlaltca commented 11 years ago

From GODZilla...@gmail.com on November 08, 2009 01:13:48

Can't reproduce issue, works as expected with PRADO 3.1.6 on WinXP Apache 2.2.x / nginx0.7.x in Firefox 3.0.11 & 3.5.5, IE 8, Safari 4, Chrome 3, Opera 9.6 Maybe the callback takes a little longer, you should verify this using Firebug!?

Test: <com:TActiveTextBox ID="TextBox1" ValidationGroup="Group1" /> <com:TActiveButton Text="Submit" ValidationGroup="Group1" OnCallback="buttonClickedCallback" ActiveControl.EnableUpdate="true"/> <com:TActiveCustomValidator ValidationGroup="Group1" ControlToValidate="TextBox1" OnServerValidate="serverValidate" ActiveControl.EnableUpdate="true" Text="You must enter 'test'"/>

public function serverValidate($sender, $param) { if($param -> getValue() !== 'test') $param -> setIsValid(false); }

public function buttonClickedCallback($sender, $param) { if($this -> getIsValid()) $sender -> setText('Success'); }

Status: Invalid

ctrlaltca commented 11 years ago

From rojaro@gmail.com on March 16, 2011 12:41:46

See the discussion at http://www.pradoframework.com/forum/index.php?topic=6782.0

Status: New
Labels: -Milestone-3.1.7 Milestone-3.1.8

ctrlaltca commented 11 years ago

From rojaro@gmail.com on March 16, 2011 12:42:10

Issue 60 has been merged into this issue.

ctrlaltca commented 11 years ago

From ctrlal...@gmail.com on April 27, 2011 05:11:46

related comment: http://www.pradoframework.com/forum/index.php?topic=6782.msg57217#msg57217 I'm attaching a patch that enables "postback after validation callback" to fix the problem when using a TButton with a TActiveCustomValidator

Attachment: 103.diff

ctrlaltca commented 11 years ago

From rojaro@gmail.com on April 27, 2011 11:57:34

Although your fix looks somewhat weird to me and in absence of a better idea on my side, i've just applied your patch to the trunk ( r2889 ).

Thanks for contributing :-)

Status: Fixed

ctrlaltca commented 11 years ago

From thomas.h...@gmail.com on June 28, 2011 06:31:38

This patch destroyed some of our forms. Usually we are combining multiple Validators for a single button (see attached sample).

I reverted the patch and everythink worked fine again. (Prado 3.1.9)

Attachment: pradobug

ctrlaltca commented 11 years ago

From ctrlal...@gmail.com on June 28, 2011 08:58:45

I don't fully get your code, the php part seems to have been cutpasted and refers to $this->selectBrand that doesn't exist. Thus, a generation will be emitted and $param->Value will be always set to false, triggering the TActiveCustomValidator.

Anyway, if i get the problem, you're attaching 2 validators (one required field and another to check the actual value) to a TTextBox. I've modified a bit your example and created a testcase. It seems to work here using the following procedure: 1) push the button => both validators triggers their error 2) enter 'a' in the textbox and push the button => only the TActiveCustomValidator error gets shown 3) enter 'Prado' in the textbox and push the button => Postback gets executed Can you reproduce the error on this example? if yes, please report the modifications and the procedure you're following.

Attachment: Home.page Home.php

ctrlaltca commented 11 years ago

From thomas.h...@gmail.com on June 29, 2011 03:48:47

Yes the code was cutpasted and cleaned up ;-). I've successfully tracked down the error. It happens if you use a template based layout.

In the template file "MyTemplate.tpl" there is a TContentPlaceHolder which references to the TContent with the ID "main". The Content Element is defined in the "Home.page" file. If i look at the source code of the page the ID of inputIdentifier gets extendet to "ctl0$main$inputIdentifier". As a conclusion the javascript code gets altered too, but i think there is a problem with the id reference (alters between ctl0$main$inputIdentifier and ctl0_main_inputIdentifier). Attached you can find e a comparison of the old an new source code (pagesource.txt).

I've also altered the helloworld sample to produce the error. There are two behaviours:

*) Behaviour A (Problem) 1) Enter 'Prado' and click directly on "Execute transaction" - the page will refresh, but nothing happens at all.

*) Behaviour B (Working as expected) 1) Push the button - both validators trigger 2) Enter 'Prado' in the textbox and press the tab button - the validators will disappear 3) Push the button - the message "executeTransaction ok" is being displayed correctly

Thank you for your fast reply!

Attachment: pagesource.txt home.tar.gz

ctrlaltca commented 11 years ago

From ctrlal...@gmail.com on July 02, 2011 06:56:46

I'd reworked the previous patch a little to address this issue and committed it on trunk/ as http://code.google.com/p/prado3/source/detail?r=3006 . It fixes your testcase in my tests. Can confirm that it's working for you too? i'd like to backport it on the 3.1 branch.

ctrlaltca commented 11 years ago

From thomas.h...@gmail.com on July 06, 2011 04:56:29

I've applied the patch and tested it within three different installations. Now everything is working as expected again. Great! :)

ctrlaltca commented 11 years ago

From ctrlal...@gmail.com on July 06, 2011 05:50:35

patch backported in r3008 , thank you!