Forms
The Form model, its properties, relationships and how to create dynamic forms using the FormBuilder.
Overview
The Form model is the central piece of Polyform. It holds a collection of fields, optional steps, validation rules and settings. You can attach forms to any model through a polymorphic relationship, set submission limits and control their lifecycle with statuses.
Core Properties
Settings Configuration
The settings property stores JSON configuration for form behavior:
FormStatus Enum
Forms use a string-backed enum with behavior methods that control submission acceptance and drive UI display.
PUBLISHED status accept new submissions. The isAcceptingSubmissions() method also checks opens_at, closes_at and max_submissions constraints. Relationships
Forms have several relationships to other models in the package.
Formable (Polymorphic)
Forms belong to a parent entity via a morphTo relationship. Add the HasPolyforms trait to your models:
Other Relationships
- fields - HasMany FormField (all fields in the form)
- submissions - HasMany FormSubmission (all submission records)
- steps - HasMany FormStep (multi-step form steps)
- webhooks - HasMany FormWebhook (webhook endpoints)
Computed Attributes
- is_open - Whether the form is currently accepting submissions
- is_multi_step - Whether the form has multiple steps
- submission_count - Cached count of submissions (use
withCount('submissions'))
Creating Forms
Using the Facade
Create forms directly with the Polyform facade:
Using the FormBuilder
The FormBuilder gives you a chainable API with 26+ field methods:
Extensibility
Forms reference all related models via config('polyform.models.xxx'), so you can extend or swap out any model class. See the configuration docs for details.