---
title: Form Renderer
---
# Form Renderer
The Form Renderer component displays forms to your users and handles submission processing.
## Basic Usage
### By Slug (Recommended)
```blade
```
### By Form ID
```blade
```
## Component Properties
| Property | Type | Default | Description |
|----------|------|---------|-------------|
| `slug` | string | null | Form slug to display |
| `form-id` | int | null | Form ID to display |
| `success-message` | string | null | Override default success message |
| `redirect-url` | string | null | URL to redirect after submission |
| `show-title` | bool | true | Show form title |
| `show-description` | bool | true | Show form description |
| `css-class` | string | '' | Additional CSS classes |
## Examples
### Custom Success Message
```blade
```
### Redirect After Submission
```blade
```
### Hide Title and Description
```blade
```
### Custom Styling
```blade
```
## Form States
The renderer handles several form states:
### Loading State
While the form is loading:
```blade
Loading form...
```
### Success State
After successful submission, displays the success message or redirects.
### Error State
Validation errors are displayed inline next to each field.
## Customizing the Form View
Publish the views to customize:
```bash
php artisan vendor:publish --tag=forms-views
```
Edit `resources/views/vendor/forms/livewire/form-renderer.blade.php`.
### View Structure
```blade
{{-- resources/views/vendor/forms/livewire/form-renderer.blade.php --}}
```
## Custom Field Templates
Create custom field templates in `resources/views/vendor/forms/partials/fields/`:
```blade
{{-- resources/views/vendor/forms/partials/fields/text.blade.php --}}
```
## Embedding in Controllers
Access form data in your own controllers:
```php
use ArtisanPackUI\Forms\Services\FormService;
class PageController extends Controller
{
public function show(FormService $formService, string $slug)
{
$form = $formService->getBySlug($slug);
return view('page', [
'form' => $form,
]);
}
}
```
Then in your view:
```blade
@if ($form && $form->is_active)
@else
This form is currently unavailable.
@endif
```
## Handling Submission Events
Listen for form submission in your JavaScript:
```javascript
document.addEventListener('livewire:initialized', () => {
Livewire.on('form-submitted', (event) => {
const { formId, submissionId } = event;
// Track conversion
gtag('event', 'form_submission', {
'form_id': formId,
});
});
});
```
## AJAX Submission
Forms submit via Livewire by default (AJAX). For traditional form submission:
```blade
```
## Accessibility
The form renderer follows WCAG guidelines:
- Proper label associations
- ARIA attributes for errors
- Focus management
- Keyboard navigation
- Screen reader announcements
## Next Steps
- [Submissions](./submissions.md) - View and manage submissions
- [Notifications](./notifications.md) - Configure email notifications
- [Multi-Step Forms](./multi-step-forms.md) - Multi-step form display