Hidden
The Hidden PHP field adds a value to form data without rendering a visible control. Its frontend presenter is named HiddenInput and renders a native <input type="hidden"> only when it has a name.
Basic Usage
use InertiaUI\Forms\Fields\Hidden;
Hidden::make('type')->default('contact');
Hidden::make('source')->default('web');
Hidden::make('version')->default(2);default() provides the initial form-data value for the hidden field. The generated HiddenInput reads the current value from form data, so later updates to the package form state remain authoritative.
Model Binding
A form bound to a model or array makes the field read its named value like other PHP fields. The default is used only when the bound data does not contain that path.
// In your controller
$form = EditPostForm::make()->bind($post);
// In your form class
Hidden::make('user_id')->default(auth()->id());Nested names use Laravel's normal dotted lookup on the PHP side.
Validation and Conditional Inclusion
Hidden fields may still participate in backend validation, authorization, and conditional inclusion:
Hidden::make('source')
->default('web')
->required()
->rules(['string', 'in:web,partner'])
->visibleWhen('channel', 'online')
->clearWhenHidden()
->authorizedWhen(fn () => auth()->check());rule(), rules(), required(), and nullable() affect Laravel validation. authorize(), authorizedWhen(), and authorizedUnless() decide whether the field participates in the form at all. The visibleWhen() and hiddenWhen() APIs decide whether the hidden value is included by the generated field renderer. clearWhenHidden() resets its form-data value to an empty string when the condition excludes it. See Conditional Visibility, Authorization, and Validation.
The compact Hidden serialization intentionally contains only component, name, optional visibility, and clearWhenHidden when enabled. It has no label, help, error, disabled, readonly, presentation, or interactive precognitive state. Although precognitive() is inherited from the base PHP field, it is not serialized for Hidden and provides no interactive validation trigger.
Hidden uses the shared field APIs for model defaults, validation rules, conditional inclusion, and authorization. It also supports Laravel when(), unless(), tap(), and registered macros as fluent construction utilities.
Using the Component Directly
HiddenInput is exported from each package's components subpath. You may use it for standalone hidden values, or pass a serialized field while rendering forms manually.
<script setup lang="ts">
import { ref } from 'vue'
import { HiddenInput } from '@inertiaui/form-vue/components'
const source = ref('newsletter')
</script>
<template>
<HiddenInput
v-model="source"
name="source"
form="signup-form"
data-testid="signup-source"
/>
</template>import { useState } from 'react'
import { HiddenInput } from '@inertiaui/form-react/components'
export function SignupSource() {
const [source, setSource] = useState('newsletter')
return (
<HiddenInput
name="source"
value={source}
onValueChange={setSource}
form="signup-form"
data-testid="signup-source"
/>
)
}Pass a name and bind the value. Native attributes and listeners target the underlying native input. See Native Attributes And Events.