<!--!
This file is a part of MediaDrop (http://www.mediadrop.net),
Copyright 2009-2014 MediaDrop contributors
For the exact contribution history, see the git revision log.
The source code contained in this file is licensed under the GPLv3 or
(at your option) any later version.
See LICENSE.txt in the main project directory, for more information.
-->
<form xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      id="${id}"
      name="${name}"
      action="${action}"
      method="${method}"
      class="${css_class}"
      py:attrs="attrs">
	<xi:include href="../helpers.html" />
	<span py:if="error and not error.error_dict" class="field-error" py:content="error" />
	<table class="field-list" py:attrs="list_attrs">
		<tbody>
			<py:for each="i, field in enumerate(fields)"
			        py:with="required = field.is_required and ' required' or None;
			                 help_url = getattr(field, 'help_url', None);
			                 is_submit = getattr(field, 'type', None) == 'submit';
			                 render_label = show_labels and not field.suppress_label;
			                 render_error = error is not None and not field.show_error;">
				<tr py:if="field.name == 'url'">
					<td>
						<br />
						<div class="field-error"
						     py:if="'_the_form' in tmpl_context.form_errors"
						     py:content="tmpl_context.form_errors['_the_form']">
							Display the error from the media controller, if any
						</div>
					</td>
				</tr>
				<tr class="title" py:if="render_label and not (is_submit or field.show_error)">
					<td>
						<label py:if="render_label" py:content="field.label_text and _(field.label_text) or None" id="${field.id}-label" class="form-label" for="${field.id}" />
						<a py:if="field.help_text and help_url" py:content="field.help_text and _(field.help_text) or None" href="${help_url}" class="field-help" />
						<span py:if="field.help_text and not help_url" py:content="field.help_text and _(field.help_text) or None" class="field-help" />
						<span py:if="not field.show_error" class="field-error" py:content="error_for(field)" />
					</td>
				</tr>
				<tr>
					<td class="${render_error and (error_for(field) is not None and 'err' or 'noerr') or ''}">
						${field.display(value_for(field), **args_for(field))}

						<!-- The following 4 elements are used only by the SwiffUploadManager javascript -->
						<div py:if="field.name == 'file'" id="bottombar">
							<button id="browse-button" class="mcore-btn f-lft"><span>Choose a file to upload</span></button>
							<div id="file-info" class="f-lft" />
						</div>
					</td>
				</tr>
				<tr py:if="field.name == 'description'" class="${field.name}-rel">
					<td py:content="xhtml_description('description')" />
				</tr>
			</py:for>
		</tbody>
	</table>
</form>
