Still Plagued With Date Formatting Bug in Text Field
I asked this question about 10 days or so ago but I haven't gotten (or at least seen) an answer. I have looked for the answer in Zope docs until my eyes bleed and I just can't figure this out. I have a text field called start_date. I set its default value to today's date by setting its value to (_DateTime().strftime("%b. %d, %Y")) The date shows up in the field, but only the first item of the formatted string displays. In this example, the field contains "Apr." and that's it. Now if I set the default value of a textarea to the same exact value, the date displays correctly. Anybody have *any* idea what in the world is going on here?
On Tue, Apr 30, 2002 at 05:31:21PM -0700, Dan Shafer wrote:
I have a text field called start_date. I set its default value to today's date by setting its value to (_DateTime().strftime("%b. %d, %Y"))
The date shows up in the field, but only the first item of the formatted string displays. In this example, the field contains "Apr." and that's it. Now if I set the default value of a textarea to the same exact value, the date displays correctly.
Any chance your field is rendering as: <input type=text name=start_date value=Apr. 30, 2002> instead of: <input type=text name=start_date value="Apr. 30, 2002"> ? -- Mike Renfro / R&D Engineer, Center for Manufacturing Research, 931 372-3601 / Tennessee Technological University -- renfro@tntech.edu
At 11:21 PM 4/30/2002 -0500, Mike Renfro wrote:
On Tue, Apr 30, 2002 at 05:31:21PM -0700, Dan Shafer wrote:
I have a text field called start_date. I set its default value to today's date by setting its value to (_DateTime().strftime("%b. %d, %Y"))
The date shows up in the field, but only the first item of the formatted string displays. In this example, the field contains "Apr." and that's it. Now if I set the default value of a textarea to the same exact value, the date displays correctly.
Any chance your field is rendering as:
<input type=text name=start_date value=Apr. 30, 2002>
instead of:
<input type=text name=start_date value="Apr. 30, 2002">
I suppose that's possible. There are no quotation marks showing in the field. But if I'm using strftime(), I don't see how this could'should be happening.
?
-- Mike Renfro / R&D Engineer, Center for Manufacturing Research, 931 372-3601 / Tennessee Technological University -- renfro@tntech.edu
On Wednesday 01 May 2002 12:58 am, Dan Shafer allegedly wrote: [snip]
Any chance your field is rendering as:
<input type=text name=start_date value=Apr. 30, 2002>
instead of:
<input type=text name=start_date value="Apr. 30, 2002">
I suppose that's possible. There are no quotation marks showing in the field. But if I'm using strftime(), I don't see how this could'should be happening.
If the quotes are missing, then that is your problem. strftime won't put quotes around it for you. How are you generating this html? ZPT, DTML or Python? Show us the source code of your template. -Casey
OK, thanks for the continuing help. I'm generating the contents of this particular field in a DTML Document inside a <FORM> tag with this line (beginning and ending angle brackets removed to avoid rendering problems):: input type="text" name="start_date" value=<dtml-var "(_.DateTime().strftime(:%b %d, %Y"))"> As I think I said in a previous note, but just for the sake of completeness, if I change tthat to use a textarea object instead of a text field, the date displays correctly. The text field is more than wide enough to accommodate the entire string. Thanks for any suggestions. This one has me completely baffled. At 09:24 AM 5/1/2002 -0400, Casey Duncan wrote:
On Wednesday 01 May 2002 12:58 am, Dan Shafer allegedly wrote: [snip]
Any chance your field is rendering as:
<input type=text name=start_date value=Apr. 30, 2002>
instead of:
<input type=text name=start_date value="Apr. 30, 2002">
I suppose that's possible. There are no quotation marks showing in the field. But if I'm using strftime(), I don't see how this could'should be happening.
If the quotes are missing, then that is your problem. strftime won't put quotes around it for you. How are you generating this html? ZPT, DTML or Python?
Show us the source code of your template.
-Casey
Try: <input type="text" name="start_date" value="<dtml-var ZopeTime fmt="%b %d, %Y">"> Be sure to include the outer quotes on the value attribute. hth, -Casey On Wednesday 01 May 2002 10:51 am, Dan Shafer allegedly wrote:
OK, thanks for the continuing help.
I'm generating the contents of this particular field in a DTML Document inside a <FORM> tag with this line (beginning and ending angle brackets removed to avoid rendering problems)::
input type="text" name="start_date" value=<dtml-var "(_.DateTime().strftime(:%b %d, %Y"))">
As I think I said in a previous note, but just for the sake of completeness, if I change tthat to use a textarea object instead of a text field, the date displays correctly. The text field is more than wide enough to accommodate the entire string.
Thanks for any suggestions. This one has me completely baffled.
Thanks, Casey, on two fronts. First, this worked! Problem solved. Second, I never heard of ZopeTime. I don't find it in the Zope Book anywhere. It is certainly cleaner to use than (_.DateTime()), which I always have syntax issues with when I try to format its output. At 11:00 AM 5/1/2002 -0400, Casey Duncan wrote:
Try:
<input type="text" name="start_date" value="<dtml-var ZopeTime fmt="%b %d, %Y">">
Be sure to include the outer quotes on the value attribute.
hth,
-Casey
On Wednesday 01 May 2002 10:51 am, Dan Shafer allegedly wrote:
OK, thanks for the continuing help.
I'm generating the contents of this particular field in a DTML Document inside a <FORM> tag with this line (beginning and ending angle brackets removed to avoid rendering problems)::
input type="text" name="start_date" value=<dtml-var "(_.DateTime().strftime(:%b %d, %Y"))">
As I think I said in a previous note, but just for the sake of completeness, if I change tthat to use a textarea object instead of a text field, the date displays correctly. The text field is more than wide enough to accommodate the entire string.
Thanks for any suggestions. This one has me completely baffled.
On Thursday 02 May 2002 12:47 pm, Dan Shafer wrote:
Thanks, Casey, on two fronts. First, this worked! Problem solved. Second, I never heard of ZopeTime. I don't find it in the Zope Book anywhere. It is certainly cleaner to use than (_.DateTime()), which I always have syntax issues with when I try to format its output.
i would suggest getting ZQR http://www.zope.org/Members/ZQR it may be a bit outdated, but it still applies. it never left my desktop :) and get Dieter's excellent DocFinder or a Zope Product wrapper DocFinderEverywhere so that all available methods will be visible. just my .02 -- http://www.kedai.com.my/ http://www.kedai.com.my/eZine http://www.zope.org/Members/kedai http://www.my-zope.org If you SMELLLL...
At 12:57 PM 5/2/2002 +0800, Bakhtiar A Hamid wrote:
On Thursday 02 May 2002 12:47 pm, Dan Shafer wrote:
Thanks, Casey, on two fronts. First, this worked! Problem solved. Second, I never heard of ZopeTime. I don't find it in the Zope Book anywhere. It is certainly cleaner to use than (_.DateTime()), which I always have syntax issues with when I try to format its output.
i would suggest getting ZQR http://www.zope.org/Members/ZQR
it may be a bit outdated, but it still applies. it never left my desktop :)
I have it. I printed it out. I forgot I had it. I have now put it in a big red binder so I won't forget it again. Thanks for the reminder. I tend to treat the printed manual as sort of semi-official and figure if it isn't in there and it isn't in the Tips and How-Tos (which I've also downloaded to my desktop and search all the time), then it's time to ask. I've added ZQR to my human search path.
and get Dieter's excellent DocFinder or a Zope Product wrapper DocFinderEverywhere so that all available methods will be visible.
I find DocFinderEverywhere, but not the original. I'll install it and experiment with it. Thanks for the pointer. So much to learn about!
just my .02
--
http://www.kedai.com.my/ http://www.kedai.com.my/eZine http://www.zope.org/Members/kedai http://www.my-zope.org If you SMELLLL...
On Wed, May 01, 2002 at 07:51:33AM -0700, Dan Shafer wrote:
OK, thanks for the continuing help.
I'm generating the contents of this particular field in a DTML Document inside a <FORM> tag with this line (beginning and ending angle brackets removed to avoid rendering problems)::
input type="text" name="start_date" value=<dtml-var "(_.DateTime().strftime(:%b %d, %Y"))"> Should be <input type="text" name="start_date" value="<dtml-var "(_.DateTime().strftime("%b %d, %Y")>">
html parsing regards the first space not in a quoted object to be a token, which if not a keyword is silently ignored. So you input is being trucated after the first space. jim Penny
As I think I said in a previous note, but just for the sake of completeness, if I change tthat to use a textarea object instead of a text field, the date displays correctly. The text field is more than wide enough to accommodate the entire string.
Thanks for any suggestions. This one has me completely baffled.
At 09:24 AM 5/1/2002 -0400, Casey Duncan wrote:
On Wednesday 01 May 2002 12:58 am, Dan Shafer allegedly wrote: [snip]
Any chance your field is rendering as:
<input type=text name=start_date value=Apr. 30, 2002>
instead of:
<input type=text name=start_date value="Apr. 30, 2002">
I suppose that's possible. There are no quotation marks showing in the field. But if I'm using strftime(), I don't see how this could'should be happening.
If the quotes are missing, then that is your problem. strftime won't put quotes around it for you. How are you generating this html? ZPT, DTML or Python?
Show us the source code of your template.
-Casey
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (5)
-
Bakhtiar A Hamid -
Casey Duncan -
Dan Shafer -
Jim Penny -
Mike Renfro