Skip to main content

Form

This model defines a form, including a list of form controls to submit data to the page.

Classname

Photon\CmsEngine\Model\Element\Form

Attributes

AttributeTypeDescription
$idintegerThe id of this form in the database, where the form is content managed
$titlestringThe title of the form
$controlsarrayAn array of form controls that make up this form page
$errorsarrayAn array of errors found in the form following validation
$actionstringThe content of the action attribute of the form HTML element
$methodstringThe content of the method attribute of the form HTML element
$formHeadingstringThe title of this form page
$instructionsstringRich text content that makes up the instructions of the form page
$primaryActionFormControlThe form control that forms the primary action of the form, often a submit button
$secondaryActionFormControlThe form control that forms the secondary action of the form, often a cancel or back button
<?php

use Photon\CmsEngine\Model\Element\Form;
use Photon\CmsEngine\Model\Element\FormControl;

$form = new Form();
$form->setTitle($title);
$form->setMethod('post');

$control = new FormControl();
$control->setName('_token');
$control->setType('hidden');
$form->addControl($control);

$control = new FormControl();
$control->setLabel($emailLabel);
$control->setName('email');
$control->setType('email');
$control->setValue('');
$control->setMandatory(true);
$control->setAutocomplete(false);
$form->addControl($control);

$control = new FormControl();
$control->setLabel($passwordLabel);
$control->setName('password');
$control->setType('password');
$control->setValue('');
$control->setMandatory(true);
$control->setAutocomplete(false);
$form->addControl($control);

$control = new FormControl();
$control->setLabel($signinButtonLabel);
$control->setName('jaduSignInButton');
$control->setType('submit');
$form->setPrimaryAction($control);