def as_select(self, _items=None, **kwargs):
attrs = self.extra.copy()<EOL>attrs.update(kwargs)<EOL>attrs['<STR_LIT:name>'] = self.name<EOL>if not self.optional:<EOL><INDENT>attrs['<STR_LIT>'] = True<EOL><DEDENT>html = [u'<STR_LIT>' % get_html_attrs(attrs)]<EOL>values = [self.to_string(**attrs)] or []<EOL>items = _items or self.items<EOL>for item in items:<EOL><INDENT>if isinstance(item, list):<EOL><INDENT>html.extend(self._render_optgroup(item, values))<EOL><DEDENT>else:<EOL><INDENT>html.append(self._render_option(item, values))<EOL><DEDENT><DEDENT>html.append(u'<STR_LIT>')<EOL>return Markup('<STR_LIT:\n>'.join(html))<EOL>
Render the field as a `<select>` element.

        :param **kwargs:
            Named paremeters used to generate the HTML attributes of each item.
            It follows the same rules as `get_html_attrs`