def render(self, name, value, attrs=None): if value is None: value = "" # default value final_attrs = self.build_attrs(attrs, name=name) options = [] if not isinstance(self.field, yyafl.fields.ChoiceField): raise IncompatibleWidget(u"Widget named %s is incompatible with select" % name) for option in self.field.allowed_values: option_attrs = {"value": option} if value == option: option_attrs["selected"] = u"selected" options.append(u"<option %s>" % flatatt(option_attrs) + self._get_value(option) + u"</option>") return u"<select" + flatatt(final_attrs) + u">" + u"".join(options) + u"</select>"
def render(self, name, value, attrs=None): if value is None: value = "" final_attrs = self.build_attrs(attrs, type=self.input_type, name=name) if value != "": final_attrs["value"] = smart_unicode(value) return u"<input%s />" % flatatt(final_attrs)
def render(self, name, value, attrs=None): if value is None: value = "" # default value final_attrs = self.build_attrs(attrs, name=name) return u"<textarea" + flatatt(final_attrs) + u">" + smart_unicode(value) + u"</textarea>"