Neuron-PHP

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

$_contactService  : ContactService
$_sessionManager  : SessionManager|null

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

Methods

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
string

renderField()

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
string

tokenScript()

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
Return values
string
On this page

Search results