<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}"
				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}"
				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 id="helper_callback_fields::callback_fields" arg-data="{$listener}" />
			</xf:formrow>

			<xf:numberboxrow name="execute_order" value="{$listener}"
				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}"
				label="{{ phrase('description') }}" />

			<xf:macro id="addon_macros::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>