CLIFFORD ILKAY wrote:

That's very strange. We've never seen that sort of thing, and we use non-validated fields all of the time.

I'll send the code to you privately.

Roger.

I specified:

newForm.addField(Fields.TextField('mname',[Validators.MaxLength(25)],label="Middle Name"))

It made no difference in the width of the field that was rendered. I specified MaxLength(6) for Salutation and both fields were the same width, and no different than when I had not specified any MaxLength.

MaxLength is a validator; it has no affect on the painting of the form field (tag). There is also an attribute of <input> tags in html that is called "maxlength". It's just a bit of confusion.


For example:
>>> from FormKit import Fields
>>> t = Fields.TextField('foo')
>>> t.tag()
'<input type="text" id="field_foo" name="foo" value="" />'
>>> t = Fields.TextField('foo',attributes={'maxlength':6})
>>> t.tag()
'<input type="text" id="field_foo" name="foo" value="" maxlength="6" />'


The "right way" to do it is to use CSS though.


I do not know of a way to specify the width of a given text entry field in a form with CSS. When you think about it, it makes sense as CSS operates on classes of things, not individual instances of things.

CSS operates on classes, yes, also on id's, also on individual elements. It's very flexible. The best way is certainly to add classes (in fact, we have hacked our own FK to always include stock classes on input items, since we almost always style them).


Here are some (other) ways:

>>> t = Fields.TextField('foo')
>>> t.addStyle({'width':'200px;'})
>>> t.tag()
'<input type="text" id="field_foo" name="foo" value="" style="width:200px;" />'


or, without using addStyle, you can have a stylesheet like this:

<style>
   #field_foo { width: 200px; border: 2px solid blue; }
</style>

or even:

>>> t = Fields.TextField('foo')
>>> t.addClass( 'myClass' )
>>> t.tag()
'<input type="text" id="field_foo" name="foo" value="" class="myClass" />'

and then

<style>
   .myClass { width: 200px; background-color:yellow;}
</style>


It's useful to open up fields in an interactive session (like PyCrust) and poke in it; there are all kinds of useful methods, like setting the access key and tab order in forms.


This is also the way to add javascript or whatever.




-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to