<?php

namespace JetStudioModule\DataModel;

use Jet\MVC_View;
use Jet\Tr;
use Jet\UI;

/**
 * @var MVC_View $this ;
 */

$relation = DataModels::getCurrentRelation();

$form = $relation->getEditForm();


?>
<?=$form->start();?>

<div class="form-fields">
	<div><?= Tr::_( 'Related model:' ) ?></div>
	<div>
		<a href="?class=<?= $relation->getRelatedDataModelClassName() ?>"><?= $relation->getRelatedDataModelName() . ' (' . $relation->getRelatedDataModelClassName() . ')' ?></a>
	</div>
	
	<?=$form->field( 'join_type' );?>

	<div></div>
	<div>
		<br>
		<div style="display: grid;grid-template-columns: 1fr auto 1fr;gap: 10px;align-items: center">
		<?php
		$form->setDoNotTranslateTexts( true );
		foreach( $relation->getRelatedDataModel()->getProperties() as $property ):
			if( !$form->fieldExists( 'glue_' . $property->getName() ) ) {
				continue;
			}
			
			$f = $form->field( 'glue_' . $property->getName() );
			?>
			<?=$f->label()?>
			<div><?=UI::icon('arrows-left-right-to-line')?></div>
			<div><?=$f->input()?></div>
			<?php
		endforeach;
		
		$form->setDoNotTranslateTexts( false );
		?>
		</div>
	</div>
</div>

<?=$form->end();?>

