<xf:if is="$widget.isInsert()">
	<xf:title>{{ phrase('add_widget') }}</xf:title>
<xf:else />
	<xf:title>{{ phrase('edit_widget:') }} {$widget.title}</xf:title>
</xf:if>

<xf:pageaction if="$widget.isUpdate()">
	<xf:button href="{{ link('widgets/delete', $widget) }}" icon="delete" overlay="true" />
</xf:pageaction>

<xf:form action="{{ link('widgets/save', $widget) }}" class="block" ajax="true">
	<div class="block-container">
		<div class="block-body">

			<xf:formrow
				label="{{ phrase('widget_definition') }}"
				explain="{$widgetDefinition.description}">
				{$widgetDefinition.title}
				<xf:hiddenval name="definition_id">{$widgetDefinition.definition_id}</xf:hiddenval>
			</xf:formrow>

			<hr class="formRowSep" />

			<xf:textboxrow name="widget_key" value="{$widget}"
				label="{{ phrase('widget_key') }}"
				hint="{{ phrase('required') }}"
				explain="{{ phrase('widget_key_explain') }}"
				dir="ltr" />

			<xf:textboxrow name="title" value="{$widget}"
				label="{{ phrase('title') }}"
				hint="{{ phrase('optional') }}"
				explain="{{ phrase('widget_title_explain') }}" />

			<xf:checkboxrow label="{{ phrase('display_in_positions') }}" listclass="listColumns">
				<xf:foreach loop="$widgetPositions" value="$position">
					<xf:option selected="{$widget.positions.{$position.position_id}} !== null" data-hide="true"
						label="{$position.title}">

						<xf:numberbox name="positions[{$position.position_id}]" value="{$widget.positions.{$position.position_id}|default(1)}" min="0" />
					</xf:option>
				</xf:foreach>

				<xf:explain>{{ phrase('widget_no_position_explain')|raw }}</xf:explain>
			</xf:checkboxrow>

			<xf:textboxrow name="display_condition" value="{$widget}" code="true"
				label="{{ phrase('display_condition') }}"
				explain="{{ phrase('this_should_be_entered_as_template_style_expression') }}" />

			{$widget.renderOptions()|raw}
		</div>
		<xf:submitrow sticky="true" icon="save" />
	</div>
</xf:form>