<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
      i18n:domain="plone">

<head>
    <title></title>
</head>

<body>

    <!-- This is a copy of Selection Widget with the only difference: instead
    of value itself, sending value.UID() as a parameter to get the selection
    value in veiw.-->
    <!-- Selection Widgets -->

    <metal:view_macro define-macro="view"
            tal:define="kssClassesView context/@@kss_field_decorator_view;
                        getKssClasses nocall:kssClassesView/getKssClassesInlineEditable;">
        <span metal:define-macro="selection-field-view"
            tal:define="kss_class python:getKssClasses(fieldName,
                              templateId='widgets/selection', macro='selection-field-view');
                              uid context/UID|nothing;"
            tal:attributes="class kss_class;
                            id string:parent-fieldname-$fieldName-$uid">
            <span metal:define-slot="inside"
                tal:define="display python:widget.getValueToView(field, context)"
                            i18n:translate=""
                tal:replace="structure display" />
        </span>
    </metal:view_macro>

    <metal:define define-macro="edit">

        <metal:use use-macro="field_macro|context/widgets/field/macros/edit">

            <metal:fill fill-slot="widget_body"
                        tal:define="vocab python:field.Vocabulary(context);
                                    vlen python:len(vocab);
                                    selectionview context/@@at_selection_widget;
                                    selection python:selectionview.getSelected(vocab, value);
                                    format python:widget.format">
                <span tal:condition="python:(vlen &lt; 4 and format == 'flex') or (format == 'radio')"
                      tal:attributes="id fieldName;">

                    <!-- Radio when the vocab is short < 4 -->

                    <div tal:condition="not: widget/render_own_label | nothing" class="formQuestion label">
                        <span tal:replace="python:widget.Label(here)"
                              i18n:translate="" />
                        <span class="required"
                              tal:condition="field/required"
                              title="Required"
                              i18n:attributes="title title_required;">&nbsp;</span>
                        <span class="formHelp"
                             tal:define="description python:widget.Description(here)"
                             tal:content="structure description"
                             tal:attributes="id string:${fieldName}_help"
                             i18n:translate="">
                          Help
                        </span>
                    </div>

                    <tal:radios repeat="item vocab">

                        <input class="noborder blurrable"
                               type="radio"
                               tal:attributes="name fieldName;
                                               id string:${fieldName}_${repeat/item/number};
                                               checked python:item in selection and 'checked' or None;
                                               value item;"
                               />

                        <label tal:content="python:vocab.getValue(item)"
                               i18n:translate=""
                               tal:attributes="for string:${fieldName}_${repeat/item/number}" />

                        <br />

                    </tal:radios>

                </span>

                <tal:longVocab condition="python:(vlen >= 4 and format == 'flex') or (format in ('select', 'pulldown'))">

                    <!-- Pulldown when longer -->

                    <label class="formQuestion"
                           tal:attributes="for python:fieldName">
                        <span tal:replace="python:widget.Label(here)"
                              i18n:translate="" />
                        <span class="required"
                              tal:condition="field/required"
                              title="Required"
                              i18n:attributes="title title_required;">&nbsp;</span>
                        <span class="formHelp"
                             tal:define="description python:widget.Description(here)"
                             tal:content="structure description"
                             tal:attributes="id string:${fieldName}_help"
                             i18n:translate="">
                          Help
                        </span>
                    </label>
                    <select tal:attributes="name fieldName;
                                            id fieldName;">

                        <option tal:repeat="item vocab"
                                tal:attributes="value item;
                                                selected python:item in selection and 'selected' or None"
                                tal:content="python:vocab.getValue(item)"
                                i18n:translate=""
                                />

                    </select>

                </tal:longVocab>

            </metal:fill>

        </metal:use>

    </metal:define>

    <div metal:define-macro="search">
        <div metal:use-macro="context/widgets/selection/macros/edit" />
    </div>

</body>

</html>
