power-media / prado3

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

Grouping ValidationGroups #450

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Right now, i can use ValidationGroup="" to group different validators to be 
executed when a button is hit.

However, this grouping is done on a site-wide level and causes problems when 
writing something like a login portlet (TTemplateControl) which is displayed 
multiple times on a page.

My current solution is something like this to add Parent->getUniqueId() to the 
ValidationGroup Attribute:

LoginPortlet.tpl
> <com:TRequiredFieldValidator
>     ValidationGroup="validateLogin<%= $this->Parent->UniqueID %>"
>     ControlToValidate="email"
>     Text="cannot be empty." />
> 
> <com:TActiveLinkButton ID="submitLoginButton" 
>     Text="login"
>     onCallback="loginSubmit"
>     ValidationGroup="validateLogin<%= $this->Parent->UniqueID %>" />

This works well for my purpose.

However, it would be nice to see such functionality inside the TBaseValidator 
implementation, e.g. via a GroupWithParent="true" attribute.

I do not fully know the policy for introducing such parameter (naming, 
implication of ViewState, etc.), thus asking for help via this issue :)

Thanks,
Raoul
PS. Thank you for your support during the last years and that you're constantly 
caring about such demanding users as me ;)

Original issue reported on code.google.com by ra...@bhatia.at on 14 Mar 2013 at 6:20

GoogleCodeExporter commented 8 years ago
The ValidationGroup property exists exactly for these cases.
Imho adding a new property that changes the behavior would just complicate up 
how thing works.
Since validation is done both clientside (javascript) and serverside (php), 
we'd need to ensure that the new GroupWithParent property is respected in both 
places; unfortunately clientside there's no concept of parent controls, since 
all controls are rendered in the same html page.
This problem introduces the need to track controls clientside introducing some 
additional complexity or just "patching" the ValidationGroup the same way you 
are already doing from inside the template.
Unless we find an elegant solution, i'd avoid adding more complexity to the 
(already messed up enough) validation code.

Original comment by ctrlal...@gmail.com on 17 Mar 2013 at 11:47

GoogleCodeExporter commented 8 years ago

Original comment by ctrlal...@gmail.com on 24 Jul 2013 at 1:46

GoogleCodeExporter commented 8 years ago
Moved to github: https://github.com/pradosoft/prado/issues

Original comment by ctrlal...@gmail.com on 1 Oct 2013 at 10:14