<?php

namespace JetStudioModule\DataModel;

use Jet\MVC_View;
use Jet\Form;
use Jet\Tr;
use Jet\UI;
use Jet\UI_dialog;

/**
 * @var MVC_View $this
 * @var DataModel_Definition_Model_Interface $related
 * @var Form $form
 */

$form = $this->getRaw( 'form' );
$related = $this->getRaw( 'related' );

echo $form->start();

echo $form->getCommonMessage();
?>
<div class="form-fields" style="grid-template-columns: 1fr 1fr;">
<?php

echo $form->field( 'related_model_class_name' );
echo $form->field( 'join_type' );
?>
</div>

<div style="display: grid;grid-template-columns: 1fr auto 1fr;gap: 10px;align-items: center">
<?php
$form->setDoNotTranslateTexts( true );
foreach( $related->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;
?>
</div>
<br>
<?php
echo UI::dialog( '', '', UI_dialog::SIZE_LARGE )->footer();
echo $form->end();

echo UI::button_save( Tr::_( 'Create' ) )->setOnClick( 'DataModel.relation.create.createSend();return false;' );


