<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
?>
<?php /* @var $block \Magento\Catalog\Block\Product\View\Options\Type\Text */ ?>
<?php $_option = $block->getOption(); ?>
<div class="field admin__field<?= $_option->getIsRequire() ? ' required _required' : '' ?>">
    <label class="admin__field-label label">
        <?= $block->escapeHtml($_option->getTitle()) ?>
        <?= /* @noEscape */ $block->getFormattedPrice() ?>
    </label>
    <div class="control admin__field-control">
        <?php if ($_option->getType() == \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_FIELD) :?>
            <input type="text"
                   id="options_<?= $block->escapeHtmlAttr($_option->getId()) ?>_text"
                   class="input-text admin__control-text <?= $_option->getIsRequire() ? ' required-entry' : '' ?> <?= $_option->getMaxCharacters() ? ' validate-length maximum-length-' . (int) $_option->getMaxCharacters() : '' ?> product-custom-option"
                   name="options[<?= $block->escapeHtmlAttr($_option->getId()) ?>]"
                   value="<?= $block->escapeHtmlAttr($block->getDefaultValue()) ?>"
                   price="<?= $block->escapeHtmlAttr($block->getCurrencyPrice($_option->getPrice(true))) ?>" />
        <?php elseif ($_option->getType() == \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_AREA) :?>
            <textarea id="options_<?= $block->escapeHtmlAttr($_option->getId()) ?>_text"
                      class="admin__control-textarea <?= $_option->getIsRequire() ? ' required-entry' : '' ?> <?= $_option->getMaxCharacters() ? ' validate-length maximum-length-' . (int) $_option->getMaxCharacters() : '' ?> product-custom-option"
                      name="options[<?= $block->escapeHtmlAttr($_option->getId()) ?>]"
                      rows="5"
                      cols="25"
                      price="<?= $block->escapeHtmlAttr($block->getCurrencyPrice($_option->getPrice(true))) ?>"><?= $block->escapeHtml($block->getDefaultValue()) ?></textarea>
        <?php endif;?>

        <?php if ($_option->getMaxCharacters()) :?>
            <p class="note"><?= $block->escapeHtml(__('Maximum number of characters:')) ?> <strong><?= (int) $_option->getMaxCharacters() ?></strong></p>
        <?php endif; ?>
    </div>
</div>
