<?php
/**
 * Field render
 * @var Form $form
 * @var string $type
 * @var array $item
 * @var string $prefix
 * @var int $item_index
 * @var string $formId
 * @var string $itemId
 * @var string $key
 * @var array $settings
 */

use ElementorPro\Modules\Forms\Widgets\Form;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

$form->remove_render_attribute( 'input' . $item_index, 'type' );
$form->remove_render_attribute( 'input' . $item_index, 'required' );
$form->add_render_attribute( 'input' . $item_index, 'class', 'elementor-field-textual ' . $prefix . 'field' );

if ( ! empty( $item[ $prefix . 'default_value' ] ) ) {
	$form->add_render_attribute( 'input' . $item_index, 'value', esc_attr( $item[ $prefix . 'default_value' ] ) );
}

if ( ! empty( $item[ $prefix . 'rows' ] ) ) {
	$form->add_render_attribute( 'input' . $item_index, 'rows', esc_attr( $item[ $prefix . 'rows' ] ) );
}

if ( ! empty( $item[ $prefix . 'placeholder' ] ) ) {
	$form->add_render_attribute( 'input' . $item_index, 'placeholder', esc_attr( $item[ $prefix . 'placeholder' ] ) );
}

$settings['attrs'] = $form->get_render_attributes( 'input' . $item_index );
$settings['itemId'] = esc_attr( $item['_id'] );
$settings['formId'] = $form->get_id();
$settings['mode'] = esc_attr( $item[ $prefix . 'mode' ] );
$settings['activeMode'] = esc_attr( $item[ $prefix . 'active_mode' ] );
$settings['height'] = (int) $item[ $prefix . 'height' ];
?>
<div
	class="<?php echo esc_attr( $type ); ?>_wrap elementor-repeater-item-<?php echo esc_attr( $itemId ); ?>"
	data-key="<?php echo esc_attr( $key ); ?>"
>
	<textarea aria-label="" <?php $form->print_render_attribute_string( 'input' . $item_index ); ?>></textarea>
</div>
