def rend(self, context, data):
        defaults = context.locate(iformless.IFormDefaults)
        value = defaults.getDefault(context.key, context)
        context.remember(data.typedValue, iformless.ITyped)

        if data.typedValue.getAttribute('immutable'):
            inp = span(id=keyToXMLID(context.key))[value]
        else:
            ##value may be a deferred; make sure to wait on it properly before calling self.input
            ## TODO: If flattening this results in an empty string, return an empty string
            inp = invisible(render=lambda c, value: self.input(
                context, invisible(), data, data.name, value),
                            data=value)

        if data.typedValue.getAttribute(
                'hidden') or data.typedValue.getAttribute('compact'):
            return inp

        context.fillSlots('label', data.label)
        context.fillSlots('name', data.name)
        context.fillSlots('input', inp)
        context.fillSlots('error', getError(context))
        context.fillSlots('description', data.description)
        context.fillSlots('id', keyToXMLID(context.key))
        context.fillSlots('value', value)

        return context.tag
Esempio n. 2
0
    def rend(self, context, data):
        defaults = context.locate(iformless.IFormDefaults)
        value = defaults.getDefault(context.key, context)
        context.remember(data.typedValue, iformless.ITyped)

        if data.typedValue.getAttribute('immutable'):
            inp = tags.span(id=keyToXMLID(context.key))[value]
        else:
            ##value may be a deferred; make sure to wait on it properly before calling self.input
            ## TODO: If flattening this results in an empty string, return an empty string
            inp = tags.invisible(
                render=lambda c, value: self.input( context, tags.invisible(), data, data.name, value ),
                data=value)

        if data.typedValue.getAttribute('hidden') or data.typedValue.getAttribute('compact'):
            return inp

        context.fillSlots( 'label', data.label )
        context.fillSlots( 'name', data.name )
        context.fillSlots( 'input', inp )
        context.fillSlots( 'error', getError(context) )
        context.fillSlots( 'description', data.description )
        context.fillSlots( 'id', keyToXMLID(context.key) )
        context.fillSlots( 'value', value )

        return context.tag
    def rend(self, context, data):
        context.remember(data, iformless.IBinding)

        from formless import configurable as conf

        configurable = conf.GroupConfigurable(data.boundTo,
                                              data.typedValue.iface)
        context.remember(configurable, iformless.IConfigurable)

        bindingNames = configurable.getBindingNames(context)

        def generateBindings():
            for name in bindingNames:
                bnd = configurable.getBinding(context, name)
                renderer = iformless.IBindingRenderer(bnd,
                                                      defaultBindingRenderer)
                renderer.isGrouped = True
                renderer.needsSkin = True
                yield invisible(data=bnd, render=renderer, key=name)

        return getError(context), form(
            id=keyToXMLID(context.key),
            enctype="multipart/form-data",
            action=calculatePostURL(context, data),
            method="post",
            **{'accept-charset': 'utf-8'
               })[fieldset[legend(_class="freeform-form-label")[data.label],
                           input(type='hidden', name='_charset_'),
                           generateBindings(),
                           input(type="submit")]]
Esempio n. 4
0
    def rend(self, context, data):
        context.remember(data, iformless.IBinding)

        from formless import configurable as conf

        configurable = conf.GroupConfigurable(data.boundTo, data.typedValue.iface)
        context.remember(configurable, iformless.IConfigurable)

        bindingNames = configurable.getBindingNames(context)

        def generateBindings():
            for name in bindingNames:
                bnd = configurable.getBinding(context, name)
                renderer = iformless.IBindingRenderer(bnd, defaultBindingRenderer)
                renderer.isGrouped = True
                renderer.needsSkin = True
                yield tags.invisible(
                    data=bnd,
                    render=renderer,
                    key=name)

        return getError(context), tags.form(
            id=keyToXMLID(context.key),
            enctype="multipart/form-data",
            action=calculatePostURL(context, data),
            method="post",
            **{'accept-charset':'utf-8'})[
                tags.fieldset[
                    tags.legend(_class="freeform-form-label")[data.label],
                    tags.input(type='hidden', name='_charset_'),
                    generateBindings(),
                    tags.input(type="submit")]]
Esempio n. 5
0
 def input(self, context, slot, data, name, value):
     if data.typedValue.getAttribute('hidden'):
         T="hidden"
     else:
         T="text"
     return slot[
         tags.input(id=keyToXMLID(context.key), type=T, name=name, value=value,
               _class='freeform-input-%s' % T)]
Esempio n. 6
0
 def input(self, context, slot, data, name, value):
     if data.typedValue.getAttribute('hidden'):
         T="hidden"
     else:
         T="text"
     return slot[
         tags.input(id=keyToXMLID(context.key), type=T, name=name, value=value,
               _class='freeform-input-%s' % T)]
Esempio n. 7
0
 def rend(self, context, data):
     defaults = context.locate(iformless.IFormDefaults)
     value = defaults.getDefault(context.key, context)
     context.remember(data.typedValue, iformless.ITyped)
     if data.typedValue.getAttribute('immutable'):
         inp = span(id=keyToXMLID(context.key))[value]
     else:
         inp = invisible(
             render=lambda c, value: self.input( context, invisible(), data, data.name, value ),
             data=value)
     if data.typedValue.getAttribute('hidden') or data.typedValue.getAttribute('compact'):
         return inp
     context.fillSlots( 'label', data.label )
     context.fillSlots( 'name', data.name )
     context.fillSlots( 'input', inp )
     context.fillSlots( 'error', getError(context) )
     context.fillSlots( 'description', data.description )
     context.fillSlots( 'id', keyToXMLID(context.key) )
     context.fillSlots( 'value', value )
     return context.tag
 def input(self, context, slot, data, name, value):
     return [
         input(id=keyToXMLID(context.key),
               name=name,
               type="password",
               _class="freeform-input-password"),
         " Again ",
         input(name="%s____2" % name,
               type="password",
               _class="freeform-input-password"),
     ]
Esempio n. 9
0
    def input(self, context, slot, data, name, value):
        ## The only difference here is the "checked" attribute; the value is still the same because
        ## we want true to be passed to the server when the checkbox is checked and the form
        ## is posted.
        node = tags.input(id=keyToXMLID(context.key), type="checkbox", name=name, value='True', _class="freeform-input-checkbox")
        if value:
            node(checked="checked")

        # HTML forms are so weak. If the checkbox is not checked, no value at all will be
        # in request.args with the name data.name. So let's force the value False to always
        # be in request.args[data.name]. If the checkbox is checked, the value True will
        # be first, and we will find that.
        return slot[node, tags.input(type="hidden", name=name, value="False")]
Esempio n. 10
0
    def input(self, context, slot, data, name, value):
        ## The only difference here is the "checked" attribute; the value is still the same because
        ## we want true to be passed to the server when the checkbox is checked and the form
        ## is posted.
        node = tags.input(id=keyToXMLID(context.key), type="checkbox", name=name, value='True', _class="freeform-input-checkbox")
        if value:
            node(checked="checked")

        # HTML forms are so weak. If the checkbox is not checked, no value at all will be
        # in request.args with the name data.name. So let's force the value False to always
        # be in request.args[data.name]. If the checkbox is checked, the value True will
        # be first, and we will find that.
        return slot[node, tags.input(type="hidden", name=name, value="False")]
Esempio n. 11
0
 def rend(self, context, data):
     return tags.input(id=keyToXMLID(context.key), type='submit', value=data.label, name=data.name, class_="freeform-button")
Esempio n. 12
0
 def fillForm(self, context, data):
     context.fillSlots( 'form-id', keyToXMLID(context.key) )
     context.fillSlots( 'form-action', calculatePostURL(context, data) )
     context.fillSlots( 'form-name', data.name )
     context.fillSlots( 'form-error', getError(context) )
Esempio n. 13
0
 def input(self, context, slot, data, name, value):
     node = input(id=keyToXMLID(context.key), type="checkbox", name=name, value='True', _class="freeform-input-checkbox")
     if value:
         node(checked="checked")
     return slot[node, input(type="hidden", name=name, value="False")]
Esempio n. 14
0
 def input(self, context, slot, data, name, value):
     return [
         tags.input(id=keyToXMLID(context.key), name=name, type="password", _class="freeform-input-password"),
         " Again ",
         tags.input(name="%s____2" % name, type="password", _class="freeform-input-password"),
     ]
 def input(self, context, slot, data, name, value):
     return slot[input(id=keyToXMLID(context.key),
                       type="file",
                       name=name,
                       _class='freeform-input-file')]
 def input(self, context, slot, data, name, value):
     return slot[textarea(id=keyToXMLID(context.key),
                          name=name,
                          _class="freeform-textarea",
                          rows=8,
                          cols=40)[value or '']]
 def input(self, context, slot, data, name, value):
     return slot[input(id=keyToXMLID(context.key),
                       type='password',
                       name=name,
                       _class='freeform-input-password')]
Esempio n. 18
0
 def input(self, context, slot, data, name, value):
     return slot[input(id=keyToXMLID(context.key), type="file", name=name,
                       _class='freeform-input-file')]
Esempio n. 19
0
 def fillForm(self, context, data):
     context.fillSlots("form-id", keyToXMLID(context.key))
     context.fillSlots("form-action", calculatePostURL(context, data))
     context.fillSlots("form-name", data.name)
     context.fillSlots("form-error", getError(context))
Esempio n. 20
0
 def input(self, context, slot, data, name, value):
     return slot[
         tags.input(id=keyToXMLID(context.key), type='password', name=name,
               _class='freeform-input-password')]
 def fillForm(self, context, data):
     context.fillSlots('form-id', keyToXMLID(context.key))
     context.fillSlots('form-action', calculatePostURL(context, data))
     context.fillSlots('form-name', data.name)
     context.fillSlots('form-error', getError(context))
Esempio n. 22
0
 def input(self, context, slot, data, name, value):
     return slot[
         tags.textarea(id=keyToXMLID(context.key), name=name, _class="freeform-textarea", rows=8, cols=40)[
             value or '']]
 def rend(self, context, data):
     return input(id=keyToXMLID(context.key),
                  type='submit',
                  value=data.label,
                  name=data.name,
                  class_="freeform-button")