<?php
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

?>
<?php
/* @var $block \Magento\Backend\Block\Widget\Form\Renderer\Fieldset\Element */
$element = $block->getElement();
$note = $element->getNote() ? '<div class="note">' . $element->getNote() . '</div>' : '';
$elementBeforeLabel = $element->getExtType() == 'checkbox' || $element->getExtType() == 'radio';
$addOn = $element->getBeforeElementHtml() || $element->getAfterElementHtml();
$entity = $element->getEntityAttribute();
$fieldId = ($element->getHtmlContainerId()) ? ' id="' . $element->getHtmlContainerId() . '"' : '';
$fieldClass = "admin__field field field-{$element->getId()} {$element->getCssClass()}";
$fieldClass .= ($elementBeforeLabel) ? ' choice' : '';
$fieldClass .= ($addOn) ? ' with-addon' : '';
$fieldClass .= ($element->getRequired()) ? ' _required' : '';
$fieldClass .= ($note) ? ' with-note' : '';
$fieldClass .= ($entity && $entity->getIsUserDefined()) ? ' user-defined type-' . $entity->getFrontendInput() : '';

$fieldAttributes = $fieldId . ' class="' . $fieldClass . '" '
    . $block->getUiId('form-field', $element->getId());
?>

<script>

var menuItems = [];
<?php if(!empty($element->getValue())): ?>
menuItems =	<?php echo $element->getValue(); ?>
<?php endif ?>
</script>

<?php if (!$element->getNoDisplay()): ?>
    <div <?php /* @escapeNotVerified */ echo $fieldAttributes ?>>
        <?php if ($elementBeforeLabel): ?>
            <?php echo $element->getElementHtml() ?>
            <?php echo $element->getLabelHtml() ?>
            <?php /* @escapeNotVerified */ echo $note ?>
        <?php else: ?>
            <div class="admin__field-control control">
                <?php /* @escapeNotVerified */ echo($addOn) ? '<div class="addon">' . $element->getElementHtml() . '</div>' : $element->getElementHtml(); ?>
                <?php echo $block->getHintHtml() ?>
                <?php /* @escapeNotVerified */ echo $note ?>
            </div>
        <?php endif; ?>
    </div>
<?php endif; ?>