fixes for composer.schema to be usable for loops member registration
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2102 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
55e801431e
commit
e8db37544f
6 changed files with 26 additions and 10 deletions
|
@ -71,7 +71,7 @@ class Form(object):
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def fields(self):
|
def fields(self):
|
||||||
return self.schema.fields
|
return [f for f in self.schema.fields if not f.readonly]
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def data(self):
|
def data(self):
|
||||||
|
|
|
@ -83,7 +83,17 @@
|
||||||
tal:attributes="name name;
|
tal:attributes="name name;
|
||||||
style python:
|
style python:
|
||||||
'width: %s' % (width and str(width)+'px' or '450px');
|
'width: %s' % (width and str(width)+'px' or '450px');
|
||||||
value data/?name" />
|
value data/?name|string:" />
|
||||||
|
</metal:textline>
|
||||||
|
|
||||||
|
|
||||||
|
<metal:textline define-macro="input_date">
|
||||||
|
<input type="text" name="field" style="width: 450px"
|
||||||
|
tal:define="width field/width|nothing"
|
||||||
|
tal:attributes="name name;
|
||||||
|
style python:
|
||||||
|
'width: %s' % (width and str(width)+'px' or '450px');
|
||||||
|
value data/?name|string:" />
|
||||||
</metal:textline>
|
</metal:textline>
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,7 +103,7 @@
|
||||||
tal:attributes="name name;
|
tal:attributes="name name;
|
||||||
style python:
|
style python:
|
||||||
'width: %s' % (width and str(width)+'px' or '450px');
|
'width: %s' % (width and str(width)+'px' or '450px');
|
||||||
value data/?name" />
|
value data/?name|string:" />
|
||||||
</metal:password>
|
</metal:password>
|
||||||
|
|
||||||
|
|
||||||
|
@ -105,7 +115,7 @@
|
||||||
rows python: height or 3;
|
rows python: height or 3;
|
||||||
style python:
|
style python:
|
||||||
'width: %s' % (width and str(width)+'px' or '450px');"
|
'width: %s' % (width and str(width)+'px' or '450px');"
|
||||||
tal:content="data/?name">
|
tal:content="data/?name|string:">
|
||||||
</textarea>
|
</textarea>
|
||||||
</metal:textarea>
|
</metal:textarea>
|
||||||
|
|
||||||
|
@ -126,7 +136,7 @@
|
||||||
tal:content="item/title"
|
tal:content="item/title"
|
||||||
tal:attributes="value item/token;
|
tal:attributes="value item/token;
|
||||||
selected python:
|
selected python:
|
||||||
item['token'] == data[name]">Mrs</option>
|
item['token'] == data.get(name)">Mrs</option>
|
||||||
</select>
|
</select>
|
||||||
</metal:dropdown>
|
</metal:dropdown>
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,8 @@ class SchemaFactory(object):
|
||||||
#default_method=getattr(field, 'default_method', None),
|
#default_method=getattr(field, 'default_method', None),
|
||||||
vocabulary=voc,
|
vocabulary=voc,
|
||||||
title=field.title,
|
title=field.title,
|
||||||
description=field.description)
|
description=field.description,
|
||||||
|
readonly=field.readonly,
|
||||||
|
nostore=getattr(field, 'nostore', False),)
|
||||||
fields.append(f)
|
fields.append(f)
|
||||||
return Schema(name=interface.__name__, *fields, **kw)
|
return Schema(name=interface.__name__, *fields, **kw)
|
||||||
|
|
|
@ -38,6 +38,8 @@ class Field(Component):
|
||||||
implements(IField)
|
implements(IField)
|
||||||
|
|
||||||
required = False
|
required = False
|
||||||
|
readonly = False
|
||||||
|
nostore = False
|
||||||
standardFieldName = None
|
standardFieldName = None
|
||||||
vocabulary = None
|
vocabulary = None
|
||||||
renderFactory = None
|
renderFactory = None
|
||||||
|
@ -73,7 +75,7 @@ class Field(Component):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def storeData(self):
|
def storeData(self):
|
||||||
return self.getFieldTypeInfo().storeData
|
return not self.nostore and self.getFieldTypeInfo().storeData
|
||||||
|
|
||||||
def getTitleValue(self):
|
def getTitleValue(self):
|
||||||
return self.title or self.name
|
return self.title or self.name
|
||||||
|
|
|
@ -78,7 +78,7 @@ class Editor(BaseInstance):
|
||||||
# don't do anything if there is an error
|
# don't do anything if there is an error
|
||||||
return formState
|
return formState
|
||||||
for f in template.components:
|
for f in template.components:
|
||||||
if not f.storeData:
|
if not f.storeData or f.readonly:
|
||||||
# a dummy field, e.g. a spacer
|
# a dummy field, e.g. a spacer
|
||||||
continue
|
continue
|
||||||
name = f.name
|
name = f.name
|
||||||
|
@ -99,7 +99,9 @@ class Editor(BaseInstance):
|
||||||
formState = FormState()
|
formState = FormState()
|
||||||
if self.template is None:
|
if self.template is None:
|
||||||
return formState
|
return formState
|
||||||
for f in self.template.fields:
|
for f in self.template.components:
|
||||||
|
if f.readonly:
|
||||||
|
continue
|
||||||
fi = f.getFieldInstance()
|
fi = f.getFieldInstance()
|
||||||
value = data.get(f.name)
|
value = data.get(f.name)
|
||||||
fi.validate(value, data)
|
fi.validate(value, data)
|
||||||
|
|
|
@ -86,7 +86,7 @@ fieldTypes = SimpleVocabulary((
|
||||||
FieldType('textarea', 'textarea', u'Textarea'),
|
FieldType('textarea', 'textarea', u'Textarea'),
|
||||||
FieldType('number', 'number', u'Number',
|
FieldType('number', 'number', u'Number',
|
||||||
inputRenderer='input_textline', instanceName='number'),
|
inputRenderer='input_textline', instanceName='number'),
|
||||||
#FieldType('date', 'date', u'Date'),
|
FieldType('date', 'date', u'Date'),
|
||||||
FieldType('fileupload', 'fileupload', u'File upload',
|
FieldType('fileupload', 'fileupload', u'File upload',
|
||||||
instanceName='fileupload'),
|
instanceName='fileupload'),
|
||||||
#FieldType('checkbox', 'checkbox', u'Checkbox'),
|
#FieldType('checkbox', 'checkbox', u'Checkbox'),
|
||||||
|
|
Loading…
Add table
Reference in a new issue