Installation
composer require tanthammar/tall-forms
Publish the config and migrations:
php artisan vendor:publish --provider="Tanthammar\TallForms\TallFormsServiceProvider" --tag="config"
php artisan vendor:publish --provider="Tanthammar\TallForms\TallFormsServiceProvider" --tag="migrations"
php artisan migrate
Basic Setup
@livewire('tall-forms::form', ['model' => \App\Models\User::class])
app/Http/Livewire/Forms/UserForm.php):
use Tanthammar\TallForms\Contracts\Form;
class UserForm implements Form
{
public function fields(): array
{
return [
'name' => 'text',
'email' => 'email',
'password' => 'password',
];
}
}
First Use Case
User model with validation:
public function fields(): array
{
return [
'name' => [
'type' => 'text',
'label' => 'Full Name',
'rules' => 'required|min:3',
],
'email' => [
'type' => 'email',
'label' => 'Email',
'rules' => 'required|email',
],
];
}
Dynamic Form Generation
fields() method to define fields dynamically (e.g., fetch from a database or API).public function fields(): array
{
return collect(config('form.fields'))->mapWithKeys(function ($field) {
return [$field['name'] => $field];
})->toArray();
}
Reusable Form Components
class BaseForm implements Form
{
public function commonFields(): array
{
return [
'created_at' => [
'type' => 'date',
'hidden' => true,
],
];
}
}
Integration with Livewire
wire:model for real-time updates:
<x-tall-forms::input name="email" wire:model="form.email" />
public function submit()
{
$this->validate($this->form->rules());
$this->form->save();
}
Nested and Array Fields
public function fields(): array
{
return [
'addresses' => [
'type' => 'repeatable',
'fields' => [
'street' => 'text',
'city' => 'text',
],
],
];
}
File Uploads
public function fields(): array
{
return [
'avatar' => [
'type' => 'file',
'rules' => 'nullable|image|mimes:jpeg,png|max:2048',
'storage' => 'public',
],
];
}
Custom Field Types
// app/Http/Livewire/CustomFields/CustomSelect.php
public function render()
{
return view('livewire.custom-fields.custom-select', [
'name' => $this->name,
'options' => $this->options,
]);
}
config/tall-forms.php:
'custom_fields' => [
'custom_select' => \App\Http\Livewire\CustomFields\CustomSelect::class,
],
Form Events
saving, saved) in your Livewire component:
protected $listeners = ['form.saving' => 'onSaving'];
public function onSaving()
{
// Pre-save logic
}
Conditional Fields
public function fields(): array
{
return [
'is_admin' => [
'type' => 'checkbox',
'label' => 'Admin User',
],
'admin_fields' => [
'type' => 'conditional',
'condition' => ['is_admin', '==', true],
'fields' => [
'role' => 'select',
],
],
];
}
Multi-Step Forms
<x-tall-forms::tabs>
<x-slot name="step1">
<x-tall-forms::input name="name" />
</x-slot>
<x-slot name="step2">
<x-tall-forms::input name="email" />
</x-slot>
</x-tall-forms::tabs>
Validation Rules Not Applying
rules are defined in the fields() array and match Laravel's validation syntax.$this->validate($this->form->rules());
File Uploads Not Working
storage path exists and is writable.rules for correct mime types and size limits.Conditional Fields Not Triggering
condition array follows [field, operator, value] format (e.g., ['is_admin', '==', true]).wire:model.live for real-time updates:
<input wire:model.live="is_admin" type="checkbox">
Nested Fields Not Saving
repeatable fields, ensure the model uses hasMany or morphMany relationships.public function addresses()
{
return $this->hasMany(Address::class);
}
Livewire State Not Persisting
TallForms handle it.resetForm() in your Livewire component.Log Field Data
submit():
dd($this->form->all());
Check Config Overrides
config/tall-forms.php for customizations (e.g., default_locale, storage_path).Inspect Blade Components
@dd($this) inside a custom component to debug props.Clear Cached Views
php artisan view:clear
Custom Field Components
resources/views/vendor/tall-forms/fields/ or app/View/Components/TallForms.Override Default Templates
php artisan vendor:publish --tag="tall-forms-views"
Hook into Form Lifecycle
FormEvents to intercept creating, updating, or deleting:
event(new FormCreating($this->form));
Add Custom JavaScript
<script>
document.addEventListener('livewire:init', () => {
Livewire.on('form-updated', (data) => {
console.log('Form updated:', data);
});
});
</script>
Lazy-Load Fields
public function fields(): array
{
return collect(request('fields', []))->mapWithKeys(function ($field) {
return [$field => $this->getFieldDefinition($field)];
})->toArray();
}
Debounce Validation
debounce to inputs to reduce server load:
<x-tall-forms::input name="email" debounce="500" />
Use wire:ignore for Heavy Components
<div wire:ignore>
<x-tall-forms::rich-text name="description" />
</div>
How can I help you explore Laravel packages today?