PDA

View Full Version : [1.1] form.getValues() && emptyText



nassaja-rus
6 Aug 2007, 5:45 AM
In addition to http://extjs.com/forum/showthread.php?t=8029&highlight=getValues()+emptyText

When I do form.getValues() that I receive all emptyText values. I think, that it is not correct. It is a bug? If it is a feature, it any wrong!

jack.slocum
6 Aug 2007, 7:27 AM
getValues() returns the values as they would be submitted to the server. Since emptyText goes to the server, this is the correct behavior.

sjivan
6 Aug 2007, 8:24 PM
I too feel that emptyText should not be submitted to the server. Take the custom Google Ext search page : http://google.com/coop/cse?cx=011693920879787039234%3Az7of1ufqccu

The "emptyText" value of the search field indicates the intent of the field but when you click the Search button without entering anything, the query parameter is empty and not "Custom Search".

Sanjiv

nassaja-rus
6 Aug 2007, 9:51 PM
And in what sense of such behaviour? Jack, you really use emptyText for sending it on a server? In any case there is a config parameter "value" if I wish to use value which will be transferred to a server by default.

It is one of those small but awfully annoying things.

jack.slocum
8 Aug 2007, 12:03 AM
No, I personally don't but the behavior has been there since the beginning and so it shouldn't be removed. The fact is, it could be used by some people as a default value.

On a side note, your server implementation should be built to ignore the emptyText anyway as there can never be any guarantee that it won't be submitted.

As for the Google search page, it is done with a css background image, not with text. ;)

nassaja-rus
8 Aug 2007, 12:24 AM
Jack, is not present desire to do superfluous checks on a server. There already it is a lot of them. Also what to do if a site works with five languages? It is possible to sink in checks and translations.

This behaviour can be corrected in 2.0?

jack.slocum
8 Aug 2007, 12:38 AM
As stated above, it has valid use cases and the functionality shouldn't be removed. It's not wrong behavior to be "corrected". If you specify you want some default text in the field when it is empty, that text is going to be there when it is empty. If you are using that feature only for informational purposes, then your system should either be set up to ignore it or you will need to clear it before sending to the server. There was a thread posted a while back where someone already wrote a simple solution to do that.

nassaja-rus
8 Aug 2007, 12:23 PM
Jack, this all is clear. That it has once been realized what to change it it would not be desirable, to that it already uses someone. Though it is not logical (IMHO) - to have two ways to set the default text for a field. And one of ways deletes this text at a choice of a field.

I simply ask to think above addition of an option which will disable similar behaviour.

For an example I have four greater forms of search, with a lot of fields. For economy of a place I use emptyText instead of label. And it conveniently and evidently. And in this case I would like to enable one option in the form of, instead of rewriting Ext.Form code Or creations additional code. I'm lazy, I do not like to write a superfluous code. Insert checks on a server because of problems with js a cursor - there is no desire.

I think this is really bothering piece which is not pleasant to many developers at this forum.

nassaja-rus
9 Aug 2007, 8:58 PM
hm, in simple I can create ext.ux extension for this and redefine some functions from ext.form. %)

dantheman
10 Aug 2007, 4:23 AM
I don't object to a null string for an empty field,
but when I've used emptyText for 'instructional' purposes
(due to lack of fine-tuned positioning options), I needed to
filter the resulting default values (which were semantically "empty" :D )

If you don't want to do the filter/checks on the server,
do so on submit from the client... I've done both.

--dan

dearsina
30 Jan 2008, 3:36 PM
A 'sendEmptyText' boolean would be ideal, because I agree with both sides of the arguement.

oxyum
16 Aug 2008, 9:11 AM
solution (http://extjs.com/forum/showthread.php?t=44295)

mjlecomte
17 Nov 2008, 10:21 AM
Just cross linking this thread to a doc suggestion:
http://extjs.com/forum/showthread.php?p=251750#post251750

broady
20 Aug 2009, 10:17 PM
My solution:



Ext.onReady(function() {
Ext.select("form").on('submit', function() {
Ext.each(Ext.ComponentMgr.all.items, function() {
if (typeof this.getValue == "undefined" || typeof this.el == "undefined") return;

if (this.getRawValue() != this.el.getValue())
this.setRawValue("");
});
});
});