<?php

use GravityKit\GravityActions\Actions\EditAction;

/**
 * @global int    $form_id         Which form we are dealing with.
 * @global array  $entries         Which entries we are modifying.
 * @global array  $selected_fields Which fields were selected.
 * @global string $view            Which view are in.
 * @global mixed  $form            Form settings.
 */
foreach ( $selected_fields as $field_id ) {
	if ( ! EditAction::is_valid_meta( $field_id ) ) {
		$field = GFAPI::get_field( $form_id, $field_id );

		if ( ! $field ) {
			continue;
		}

		if ( 'time' === $field->get_input_type() && ! empty( $field->inputs ) ) {
			foreach ( $field->inputs as $key => $input ) {
				if ( empty( $input['id'] ) ) {
					continue;
				}

				$this->render( 'components/fields/hidden', [ 'field_id' => $input['id'], 'value' => $field_values[ $input['id'] ] ?? null ] );

			}
			continue;
		}
	}

	$this->render( 'components/fields/hidden', [ 'field_id' => $field_id, 'value' => $field_values[ $field_id ] ?? null ] );
}
