Skip to content

hidden

Hidden input, optionally with a visible label.

Lte3::hidden(string $name, mixed $value = null, array $attrs = [])

Blade: lte3::components.hidden. The value is resolved as described in Value resolution, so inside a form with a model Lte3::hidden('id') takes $model->id.

{!! Lte3::hidden('parent_id', $parent->id) !!}
{!! Lte3::hidden('__tmp', '666', ['label' => 'Hidden field']) !!}
AttrTypeDefaultDescription
labelstring-When set, a .form-group with this label is printed before the input. No label by default.
helpstring-Help HTML after the input.
classstring-Classes of the input.
class_wrapstring-Wraps the field in a <div> with these classes. No wrapper by default.
disabledboolfalseAdds disabled; the field is not submitted.
attrsarray-Arbitrary HTML attributes of the input.
defaultmixed-Fallback value.
formattercallable or class-Transforms the value before rendering.

Keys from lte3.view.field_attrs (id, data-name, x-model, …) are printed on the input.

The package reads several hidden fields on submit, for example:

{{-- open this modal after the form is submitted and the page reloads --}}
{!! Lte3::hidden('_modal', '#my-modal-lg') !!}

The key names come from the config: lte3.view.modal_key (_modal) and lte3.view.next_destination_key (_destination), see Request options.

For a field named _method, old() and request values are ignored and the passed value (or the model value) is always used.

A hidden input with an id often holds data of a JS editor, e.g. Editor.js JSON:

{!! Lte3::hidden('editorjs_data', $json, ['id' => 'editorjs_data']) !!}

See Editors.

name — the value (nothing when disabled).