<?php
namespace JetStudioModule\Pages;

use Jet\MVC_View;

/**
 * @var MVC_View $this
 * @var Page $page
 */

$page = $this->getRaw( 'page' );

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

	<div class="form-fields">
		<?= $form->field( 'name' ) ?>
		
		<?= $form->field( 'is_secret' ) ?>
		<?= $form->field( 'is_active' ) ?>
		<?= $form->field( 'SSL_required' ) ?>
		<?= $form->field( 'layout_script_name' ) ?>
		<?= $form->field( 'order' ) ?>
		<?= $form->field( 'title' ) ?>
		<?= $form->field( 'menu_title' ) ?>
		<?= $form->field( 'breadcrumb_title' ) ?>
		<?= $form->field( 'icon' ) ?>
		
		
		<?php if( $form->fieldExists( 'relative_path_fragment' ) ):
			$field = $form->field( 'relative_path_fragment' );
			
			$parent = $page->getParent();
			if( $parent ) {
				$parent_URL = $parent->getURL();
			} else {
				$parent_URL = $page->getBase()->getHomepage( $page->getLocale() )->getURL();
			}
			?>

			<?= $field->label() ?>
			<div class="input-group">
				<span class="input-group-prepend" style="font-weight: bolder">
					<span class="input-group-text"><?= rtrim( $parent_URL, '/' ) ?>/</span>
				</span>
				<div>
					<?= $field->input() ?>
					<?= $field->error() ?>
				</div>
			</div>

		
		<?php else: ?>
			
			<label>URL:</label>
			<div>
				<div class="input-group">
					<span class="input-group-prepend" style=""><span class="input-group-text"> </span></span>
					
					<span class="input-group-prepend" style="bolder;border-left: none;border-right: none;">
						<span class="input-group-text"><?= $page->getURL() ?></span>
					</span>
					
					<span class="input-group-append" style=""><span class="input-group-text"></span></span>
				</div>
			</div>
		
		<?php endif; ?>
		
		<?=$form->field('meta_tags')?>
		<?=$form->field('params')?>
		<?=$form->field('http_headers')?>
	</div>
<?= $form->end() ?>
