So I know a WValidator with mandatory == false is useless .. but I have a
form where I flip it around from true to false and back a few times, and I'd
rather use setMandatory(false) rather than delete widget->validator, as
pointers are deleting are scarier than setting booleans :)
The attached patch to latest git fixes it for me.
Thanks heaps,
Matthew Sherborne
On Sun, Sep 25, 2011 at 9:05 AM, Matthew Sherborne <msherbo...@gmail.com>wrote:
> To reproduce:
>
> 1. Create a Widget with WValidator
> 2. Set the widget->validator->setMandatory(true) -- This will push new
> javascript, which is nice and good
> 3. Set the widget->validator->setMandatory(false) -- The javascript will
> not be updated this time around .. in the browser, it will still demand a
> value
>
> Lines of interest (from latest git):
>
> WValidator.C:75 - return std::string();
> WFormWidget.C:234 - if (!validateJS.empty())
>
> So basically WValidator::javaScriptValidate returns an empty string, which
> WFormWidget::validatorChanged() takes to mean "don't bother changing things
> on the client side"
>
> Thanks :)
>
diff --git a/src/Wt/WValidator.C b/src/Wt/WValidator.C
index 50632ff..cb7c588 100644
--- a/src/Wt/WValidator.C
+++ b/src/Wt/WValidator.C
@@ -71,8 +71,13 @@ std::string WValidator::javaScriptValidate() const
"""message: " + invalidBlankText().jsStringLiteral() + "}"
"};"
"})();";
- } else
- return std::string();
+ } else {
+ return "new (function() {"
+ "this.validate = function(text) {"
+ """return { valid: true }"
+ "};"
+ "})();";
+ }
}
std::string WValidator::inputFilter() const
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
witty-interest mailing list
witty-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/witty-interest