allows customisation of textarea cols/rows
This commit is contained in:
parent
40c5eb4753
commit
e6e65d31c9
|
@ -122,6 +122,11 @@ class FormDefFieldPage(Directory):
|
|||
form.add(WidgetList, 'items', title = _('Items'), element_type = StringWidget,
|
||||
value = value.get('items', []), required = True,
|
||||
element_kwargs = {'render_br': False})
|
||||
if value.get('type') == 'text':
|
||||
form.add(StringWidget, 'cols', title = _('Line length'),
|
||||
value = value.get('cols', ''))
|
||||
form.add(StringWidget, 'rows', title = _('Number of rows'),
|
||||
value = value.get('rows', ''))
|
||||
|
||||
form.add_submit("submit", _("Submit"))
|
||||
form.add_submit("cancel", _("Cancel"))
|
||||
|
@ -153,7 +158,7 @@ class FormDefFieldPage(Directory):
|
|||
|
||||
def submit(self, form):
|
||||
value = self.formdef.fields[self.field_no]
|
||||
for f in ('name', 'type', 'required', 'items'):
|
||||
for f in ('name', 'type', 'required', 'items', 'rows', 'cols'):
|
||||
w = form.get_widget(f)
|
||||
if not w:
|
||||
if value.has_key(f):
|
||||
|
|
|
@ -13,6 +13,10 @@ widget_classes = {
|
|||
'item': SingleSelectWidget,
|
||||
}
|
||||
|
||||
widget_extra_attributes = {
|
||||
'text': ('cols', 'rows'),
|
||||
}
|
||||
|
||||
|
||||
class FormDef(storage.Storable):
|
||||
key = 'id'
|
||||
|
@ -42,6 +46,11 @@ class FormDef(storage.Storable):
|
|||
kwargs = {'required': field.get('required', True)}
|
||||
if field['type'] == 'item':
|
||||
kwargs['options'] = field.get('items', ['---'])
|
||||
if widget_extra_attributes.has_key(field['type']):
|
||||
for k in widget_extra_attributes[field['type']]:
|
||||
v = field.get(k, None)
|
||||
if v is not None:
|
||||
kwargs[k] = v
|
||||
form.add(widget_classes[field['type']], "f%d" % i, title = field['name'],
|
||||
**kwargs)
|
||||
return form
|
||||
|
|
Loading…
Reference in New Issue