<xf:if is="$listener.isInsert()">
	<xf:title>{{ phrase('add_code_event_listener') }}</xf:title>
<xf:else />
	<xf:title>{{ phrase('edit_code_event_listener:') }} {$listener.event_id}</xf:title>
</xf:if>

<xf:pageaction if="$listener.isUpdate()">
	<xf:button href="{{ link('code-events/listeners/delete', $listener) }}" icon="delete" overlay="true" />
</xf:pageaction>

<xf:css src="code_event.less" />

<xf:form action="{{ link('code-events/listeners/save', $listener) }}" ajax="true" class="block">

	<div class="block-container">
		<div class="block-body">
			<xf:selectrow name="event_id" value="{$listener.event_id}"
				label="{{ phrase('listen_to_event') }}"
				data-xf-init="desc-loader"
				data-desc-url="{{ link('code-events/get-description') }}">

				<xf:option />
				<xf:options source="{$events}" />
				<xf:html>
					<div class="js-descTarget eventDescription" dir="ltr">{$listener.Event.description|raw}</div>
				</xf:html>
			</xf:selectrow>

			<xf:textboxrow name="hint" value="{$listener.hint}" maxlength="{{ max_length($listener, 'hint') }}"
				label="{{ phrase('event_hint') }}"
				explain="{{ phrase('certain_events_take_hints_that_can_limit_when_listener_is_run') }}"
				dir="ltr" />

			<hr class="formRowSep" />

			<xf:formrow rowtype="input"
				label="{{ phrase('execute_callback') }}">
				<xf:macro template="helper_callback_fields" name="callback_fields" arg-data="{$listener}" />
			</xf:formrow>

			<xf:numberboxrow name="execute_order" value="{$listener.execute_order}" min="0"
				label="{{ phrase('callback_execution_order') }}"
				explain="{{ phrase('code_event_execution_order_desc') }}" />

			<xf:checkboxrow>
				<xf:option name="active" selected="$listener.active">{{ phrase('enable_callback_execution') }}</xf:option>
			</xf:checkboxrow>

			<hr class="formRowSep" />

			<xf:textboxrow name="description" value="{$listener.description}"
				label="{{ phrase('description') }}" />

			<xf:macro template="addon_macros" name="addon_edit" arg-addOnId="{$listener.addon_id}" />

			<xf:hiddenval name="event_listener_id">{$listener.event_listener_id}</xf:hiddenval>
		</div>
		<xf:submitrow sticky="true" icon="save" />
	</div>
</xf:form>