class FileFieldSet(FieldSet): '''FieldSet aggregating fields required for file upload handling:: ''' fields = [ FileField('file', conv=convs.SimpleFile(), widget=widgets.FileInput()), Field('mode', conv=convs.EnumChoice(choices=[('existing', ''), ('transient', ''), ('empty', '')], required=True), widget=widgets.HiddenInput), Field('transient_name', conv=convs.Char(check_file_path, required=False), widget=widgets.HiddenInput), Field('original_name', conv=convs.Char(check_file_path, required=False), widget=widgets.HiddenInput), ] conv = FileFieldSetConv def __init__(self, name, **kwargs): kwargs.setdefault('fields', self.fields) kwargs.setdefault('conv', self.conv) FieldSet.__init__(self, name, **kwargs) def get_initial(self): # Redefine because FieldSet.get_initial returns dict by default, # but python value of FileFieldSet is either None, either BaseFile # instance. return None
class F(Form): fields = [ Field('name', conv=convs.Char(), widget=self.widget(classname="cls")), Field('unreadable', permissions="w", conv=convs.Char(), widget=self.widget(classname="cls")) ]
class F(Form): fields = [ Field('name', conv=convs.Char(), widget=self.widget( getter=lambda x: x.replace('value', 'display'))) ]
class CF_CheckboxField(CF_EnumField): multiple = True conv = CF_EnumChoiceConv(conv=convs.ListOf(convs.Char())) widget = CF_CheckboxWidget() @cached_property def json_prepared(self): return u', '.join(self.clean_value)
class F(Form): fields = [ Field( 'name', conv=convs.Char(), widget=self.widget(), permissions="r", ) ]
class CF_TextareaField(CF_FormField): widget = CF_TextAreaWidget() conv = convs.Char(convs.length(1, 2000)) size_classnames = { 'small': 'textarea_small', 'medium': 'textarea_medium', 'large': 'textarea_large' }
class _Form(Form): fields = [ FieldBlock('field block', fields=[ Field('number', convs.Int()), Field('title', convs.Char()), ], permissions='r'), ]
class _Form(Form): fields = [ FieldBlock('field block', [ Field('number', convs.Int()), FieldBlock('field block', [ Field('title', convs.Char()), ]), ]), ]
class F(Form): fields = [ FieldList('list', field=FieldSet(None, fields=[ Field('name', conv=convs.Char(), widget=widgets.TextInput) ])) ]
def _item_field(self, models, factory=None): return IF_StreamSelect( self.name, label=self.label, model=self.model, stream_name=self.stream_name, multiple=self.multiple, allow_create=self.allow_create, allow_select=self.allow_select, allow_delete=self.allow_delete, inshift=self.inshift, condition=self.condition, default_filters=self.default_filters, ordered=self.ordered, rel=self.rel, conv=convs.Char() )
class F(Form): fields = [Field('name', conv=convs.Char(), widget=self.widget())]
class F(Form): fields = [ Field('name', conv=convs.Char(), widget=self.widget(escape=False)) ]
class _Form(Form): fields = [Field('input', convs.Char())]