ContactFormWidget
in package
implements
IWidget
Contact form widget / shortcode.
Renders a contact form whose fields come entirely from configuration, so a single shortcode powers every contact form on the site:
[contact] -> default form [contact form="intake"] -> the "intake" form [contact form="volunteer" title="Join Us" button="Apply"]
The form posts to /contact/submit. A CSRF token is fetched client-side from /contact/token so the markup remains valid even when the page is cached.
Table of Contents
Interfaces
- IWidget
- Widget interface for extensible shortcode/widget system.
Properties
Methods
- __construct() : mixed
- getAttributes() : array<string, string>
- Supported shortcode attributes.
- getDescription() : string
- Widget description (for documentation).
- getName() : string
- Shortcode name.
- render() : string
- Render the contact form.
- consumeFlash() : array{0: ?string, 1: ?string}
- Read and clear per-form flash messages set by the controller.
- esc() : string
- HTML-escape helper.
- renderField() : string
- Render a single configured field as a Bootstrap form control.
- session() : SessionManager|null
- Lazily resolve a started session manager.
- tokenScript() : string
- Inline script (rendered once per page) that fetches a fresh CSRF token and injects it into every contact form, keeping cached markup valid.
Properties
$_contactService
private
ContactService
$_contactService
$_sessionManager
private
SessionManager|null
$_sessionManager
Methods
__construct()
public
__construct(ContactService $contactService[, SessionManager|null $sessionManager = null ]) : mixed
Parameters
- $contactService : ContactService
- $sessionManager : SessionManager|null = null
getAttributes()
Supported shortcode attributes.
public
getAttributes() : array<string, string>
Return values
array<string, string>getDescription()
Widget description (for documentation).
public
getDescription() : string
Return values
string —Widget description
getName()
Shortcode name.
public
getName() : string
Return values
string —Shortcode name (e.g., 'property-listings')
render()
Render the contact form.
public
render(array<string, mixed> $attrs) : string
Parameters
- $attrs : array<string, mixed>
-
Shortcode attributes
Return values
string —Rendered HTML
consumeFlash()
Read and clear per-form flash messages set by the controller.
private
consumeFlash(string $key) : array{0: ?string, 1: ?string}
Parameters
- $key : string
Return values
array{0: ?string, 1: ?string} —[success, error]
esc()
HTML-escape helper.
private
esc(string $value) : string
Parameters
- $value : string
Return values
stringrenderField()
Render a single configured field as a Bootstrap form control.
private
renderField(array<string|int, mixed> $field, string $idSuffix) : string
Parameters
- $field : array<string|int, mixed>
- $idSuffix : string
Return values
stringsession()
Lazily resolve a started session manager.
private
session() : SessionManager|null
Return values
SessionManager|nulltokenScript()
Inline script (rendered once per page) that fetches a fresh CSRF token and injects it into every contact form, keeping cached markup valid.
private
tokenScript() : string