class BaseLayout(twc.CompoundWidget): """ The following CSS classes are used, on the element containing both a child widget and its label. `odd` / `even` On alternating rows. The first row is odd. `required` If the field is a required field. `error` If the field contains a validation error. """ label = twc.ChildParam( 'Label for the field. Auto generates this from the ' + 'id; None supresses the label.', default=twc.Auto) help_text = twc.ChildParam('A longer description of the field', default=None) hover_help = twc.Param('Whether to display help text as hover tips', default=False) container_attrs = twc.ChildParam( 'Extra attributes to include in the element containing ' + 'the widget and its label.', default={}) resources = [twc.CSSLink(modname='tw2.forms', filename='static/forms.css')] @property def children_hidden(self): return [c for c in self.children if isinstance(c, HiddenField)] @property def children_non_hidden(self): return [c for c in self.children if not isinstance(c, HiddenField)] @property def rollup_errors(self): errors = [ c.error_msg for c in self.children if isinstance(c, HiddenField) and c.error_msg ] if self.error_msg: errors.insert(0, self.error_msg) return errors def prepare(self): super(BaseLayout, self).prepare() for c in self.children: if c.label is twc.Auto: c.label = c.id and twc.util.name2label(c.id) or ''
class TestContainer(twc.CompoundWidget): test = twc.ChildParam(default=10) test2 = twc.ChildParam()
class LayoutContainer(twc.CompoundWidget): label = twc.ChildParam(default='b')