Form

Form implements OutputableInterface

Form

Example

<?php
$form = Form::create('action', $_SESSION[$guid]['absoluteURL'].'/modules/'.$_SESSION[$guid]['module'].'/thing.php');
                
$form->addHiddenValue('address', $_SESSION[$guid]['address']);

$row = $form->addRow();
    $row->addFooter();
    $row->addSubmit();

echo $form->getOutput();
Edit this example

Methods

Inherited from BasicAttributesTrait

__construct

Create a form with a specific factory and renderer.

Form::__construct( \Gibbon\Forms\FormFactoryInterface $factory, \Gibbon\Forms\FormRendererInterface $renderer, string $action, string $method )

create

Create a form with the default factory and renderer.

static Form::create( string $id, string $action, string $method = 'post', string $class = 'smallIntBorder fullWidth standardForm' ): object

Return Value: object Form object


getFactory

Get the current factory.

Form::getFactory( ): object

Return Value: object FormFactoryInterface


setFactory

Set the factory.

Form::setFactory( \Gibbon\Forms\FormFactoryInterface $factory )

getRenderer

Get the current renderer.

Form::getRenderer( ): object

Return Value: object FormRendererInterface


setRenderer

Set the renderer.

Form::setRenderer( \Gibbon\Forms\FormRendererInterface $renderer )

getMethod

Get the current HTTP method for this form (default: post)

Form::getMethod( ): string

Return Value: string


getAction

Get the current action URL for the form.

Form::getAction( ): string

Return Value: string


addRow

Adds a Row object to the form and returns it.

Form::addRow( string $id = '' ): object

Return Value: object Row


getRow

Cet the last added Row object, null if none exist.

Form::getRow( ): object|null

Return Value: object|null


getRows

Get an array of all Row objects in the form.

Form::getRows( ): array

Return Value: array


addHiddenValue

Adds an input type=hidden value to the form.

Form::addHiddenValue( string $name, string $value )

getHiddenValues

Get an array of all hidden values.

Form::getHiddenValues( ): array

Return Value: array


getAutocomplete

Get the value of the autocomplete HTML form attribute.

Form::getAutocomplete( ): string

Return Value: string


setAutocomplete

Turn autocomplete for the form On or Off.

Form::setAutocomplete( string $value ): self

Returns Self: This method can be chained.


addConfirmation

Add a confirmation message to display before form submission.

Form::addConfirmation( string $message ): self

Returns Self: This method can be chained.


addTrigger

Adds a Trigger object that injects javascript to respond to form events.

Form::addTrigger( string $selector, object $trigger )

getTriggers

Get an array of all Trigger objects.

Form::getTriggers( ): array

Return Value: array


toggleVisibilityByClass

Adds a visibility trigger to the form by class name.

Form::toggleVisibilityByClass( string $class ): object

Return Value: object Trigger


toggleVisibilityByID

Adds a visibility trigger to the form by element ID.

Form::toggleVisibilityByID( string $id ): object

Return Value: object Trigger


loadAllValuesFrom

Loads an array of $key => $value pairs into any form elements with a matching name.

Form::loadAllValuesFrom( &$data ): self

Returns Self: This method can be chained.


loadStateFrom

Loads the state for several form elements by calling $method with values from $data.

Form::loadStateFrom( string $method, array &$data ): void

getOutput

Renders the form to HTML.

Form::getOutput( ): string

Return Value: string