{extends file=$element.methods->getTemplatePath('autocomplete')}

{block name=elementOperationsButtons append}
	{* TODO: do this later... *}
	{if $element.style.buttons and CurrentUserAccess::getInstance()->hasAccessToOption('Modules/Partners/Corporates-insert') and !$element.disabled and !$element.style.simple}
		<a href="#;" onclick="corporateInsert('{http_build_query($element.insertFields)}');" class="link">{$_LANG.formField.inputs.generalAutocomplete.buttons.addCorporate}</a>
	{/if}
{/block}

{block name=post append}

	<div>

		{$_LANG['formField']['inputs']['generalAutocomplete']['text']['name']}:
		<b>
			{if $element.companyName}{$element.companyName}
			{else}-{/if}
		</b>

		/

		{$_LANG['formField']['inputs']['generalAutocomplete']['text']['suggestions']}:
		{if !$element.suggestions}
			<i>{$_LANG['formField']['inputs']['generalAutocomplete']['text']['noSuggestions']}</i>
		{else}
			{$limit=3}
			{foreach $element.suggestions as $idCorp=>$corp}
				{if $limit>0}
					{corporateLabel ref=$idCorp}
					[<a href="#;" class="link"
						onclick="
							FormField.setValue(null, 'Engine/Form/Input/Autocomplete', null, '{$element.id}', {
								displayValue: '{$corp.alias}',
								value: '{$idCorp}'
							});
						"
					>{$_LANG['formField']['inputs']['generalAutocomplete']['buttons']['select']}</a>]
					{if !$corp@last}
						,
					{/if}
				{/if}
				{$limit=$limit-1}
			{/foreach}
			{if $limit<0}...{/if}
		{/if}

	</div>

{/block}
