<?php
/**
 *
 *
 * @var int             $form_id            Which form we are dealing with.
 * @var array           $entries            Which entries we are modifying.
 * @var array           $selected_fields    Which fields were selected.
 * @var string          $view               Which view are in.
 * @var mixed           $form               Form settings.
 * @var WP_Error        $error              Error that occurred.
 * @var ActionInterface $bulk_action_object Which bulk action rendered this modal.
 */

use GravityKit\GravityActions\Assets;
use GravityKit\GravityActions\Actions\EditAction;
use GravityKit\GravityActions\Admin;
use GravityKit\GravityActions\Actions\ActionInterface;

$left_button_attrs = [];
$left_button_classes = 'secondary featherlight-close';

if ( empty( $left_button_text ) ) {
	$left_button_text = esc_html__( 'Close', 'gk-gravityactions' );
}

if ( ! empty( $left_button_request ) ) {
	$left_button_classes = 'secondary';
	$left_button_attrs['data-js'] = 'gk-gravityactions-modal-submit';
	$left_button_attrs['data-modal-view'] = $left_button_request;
}

$left_button   = get_submit_button(
	$left_button_text,
	$left_button_classes,
	'submit',
	false,
	$left_button_attrs
);

if ( empty( $field_values ) ) {
	$field_values = [];
}

?>
<form
	class="gk-gravityactions"
	data-js="gk-gravityactions-modal-form"
>
	<?php $this->render( 'components/header' ); ?>
	<?php
		if ( ! empty( $bulk_action_object ) && $bulk_action_object instanceof ActionInterface ) {
			$this->render( 'components/modal-fields', [ 'bulk_action' => $bulk_action_object::get_key() ] );
		}
	?>

	<?php foreach ( $field_values as $key => $value ) { ?>
		<input type="hidden" name="field_values[<?php echo $key; ?>]" value="<?php echo $value; ?>"/>
	<?php } ?>

	<div class="gk-gravityactions-modal-body">

		<div class="gk-gravityactions-modal-content">

			<div class="gk-gravityactions-modal-column gk-gravityactions-modal-column-center gk-gravityactions-modal-column-full-width">

				<?php echo $error->get_error_message(); ?>

			</div>

		</div>

	</div>
	<?php $this->render( 'components/footer', [
		'total_steps'      => false,
		'left_navigation'  => $left_button,
		'right_navigation' => null,
	] ); ?>
</form>
