コード例 #1
0
ファイル: test_tags.py プロジェクト: gjhiggins/WebHelpers2
    def test_radio_button(self):
        eq_(
            radio("people", "justin"),
            u'<input id="people_justin" name="people" type="radio" value="justin" />'
        )

        eq_(
            radio("num_people", 5),
            u'<input id="num_people_5" name="num_people" type="radio" value="5" />'
        )

        eq_(
            radio("num_people", 5),
            u'<input id="num_people_5" name="num_people" type="radio" value="5" />'
        )

        eq_(
            radio("gender", "m") + radio("gender", "f"),
            u'<input id="gender_m" name="gender" type="radio" value="m" /><input id="gender_f" name="gender" type="radio" value="f" />'
        )

        eq_(
            radio("opinion", "-1") + radio("opinion", "1"),
            u'<input id="opinion_-1" name="opinion" type="radio" value="-1" /><input id="opinion_1" name="opinion" type="radio" value="1" />'
        )

        eq_(
            radio("num_people", 5, checked=True),
            u'<input checked="checked" id="num_people_5" name="num_people" type="radio" value="5" />'
        )
コード例 #2
0
ファイル: __init__.py プロジェクト: jbcnrlz/pyramid-blog
 def render(self, **kwargs):
     html = ''
     checked = kwargs['options'][0][1]
     for label, value in kwargs['options']:
         r = tags.radio(self.name, value, checked=value == checked)
         t = HTML.tag('span', c=label)
         l = HTML.tag('label', c=r+' '+t)
         html += HTML.tag('li', c=l)
     return HTML.tag('ul', class_='inputs-list', c=html)
コード例 #3
0
 def render(self, **kwargs):
     html = ''
     checked = kwargs['options'][0][1]
     for label, value in kwargs['options']:
         r = tags.radio(self.name, value, checked=value == checked)
         t = HTML.tag('span', c=label)
         l = HTML.tag('label', c=r+' '+t)
         html += HTML.tag('li', c=l)
     return HTML.tag('ul', class_='inputs-list', c=html)
コード例 #4
0
    def radio(self, name, value=None, checked=False, label=None, **attrs):
        """
        Outputs radio input.
        """
        try:
            checked = unicode(traverse_object_for_value(self.form.data, name)) == unicode(value)
        except (KeyError, AttributeError):
            pass

        return tags.radio(name, value, checked, label, **attrs)
コード例 #5
0
    def radio(self, name, value=None, checked=False, label=None, **attrs):
        """
        Outputs radio input.
        """
        try:
            checked = unicode(traverse_object_for_value(
                self.form.data, name)) == unicode(value)
        except (KeyError, AttributeError):
            pass

        return tags.radio(name, value, checked, label, **attrs)
コード例 #6
0
ファイル: helpers.py プロジェクト: nous-consulting/ututi
def select_radio(name, title, options, selected=[], help_text=None, **kwargs):
    expl = None
    if help_text is not None:
        expl = HTML.span(class_='helpText', c=help_text)

    radios = []
    for value, label in options:
        checked = value in selected
        radios.append(radio(name, value, checked, label, **kwargs))

    return HTML.div(class_='formField',
                    id='%s-field' % name,
                    c=[HTML.label(for_=name, c=[
                    HTML.span(class_='labelText', c=[title]),
                    HTML.span(class_='radioField', c=radios)]),
                       HTML.literal('<form:error name="%s" />' % name),
                       expl])
コード例 #7
0
def radio_button(name, *args, **options):
    _update_fa(options, name)
    return radio(name, *args, **options)
コード例 #8
0
 def radio(self, name, value=None, checked=False, label=None, **attrs):
     """
     Outputs radio input.
     """
     checked = self.value(name) == value or checked
     return tags.radio(name, value, checked, label, **attrs)
コード例 #9
0
ファイル: vFormRenderer.py プロジェクト: cackharot/viper-pos
 def radio(self, name, value=None, checked=False, label=None, **attrs):
     """
     Outputs radio input.
     """
     checked = self.data.get(name) == value or checked
     return tags.radio(self.prefix + name, value, checked, label, **attrs) + self.getErrorTag(name)
コード例 #10
0
ファイル: form.py プロジェクト: lowks/pyramid_orb
 def radio(self, name, value=None, checked=False, id=None, **attrs):
     checked = self.value(name) == value or checked
     return tags.radio(name, value, checked, label, **attrs)
コード例 #11
0
 def radio(self, name, value=None, checked=False, label=None, **attrs):
     """
     Outputs radio input.
     """
     checked = self.data.get(name) == value or checked
     return tags.radio(name, value, checked, label, **attrs)
コード例 #12
0
ファイル: helpers.py プロジェクト: Xion345/formalchemy
def radio_button(name, *args, **options):
    _update_fa(options, name)
    return radio(name, *args, **options)