ValidForm Builder API Documentation

ValidForm extends ClassDynamic
in package

ValidForm Builder main class - all the magic starts here.

Check out some of the following examples to get started

Example; Create a ValidForm Builder instance

$objForm = new ValidForm("cool_new_form", "Please fill out my cool form", "/awesome-submits");

Example 2; Add a field

Check out the constants section starting with for more field types

$objForm->addField(
    "first-name",
    "First name",
    ValidForm::VFORM_STRING,
    array(
        // Make this field required
        "required" => true
    ),
    array(
        // Show this error to indicate this is an required field if no value is submitted
        "required" => "This field is required"
    )
);

Example 3; Using to set default values on form fields

//*** Add a checklist
$objCheck = $objForm->addField("cool", "Cool checklist", ValidForm::VFORM_CHECK_LIST);
$objCheck->addField("Option 1", "option1");
$objCheck->addField("Option 2", "option2");
$objCheck->addField("Option 3", "option3");

// Add a standard string field
$objCheck = $objForm->addField("cool-text", "Coolest PHP Library", ValidForm::VFORM_STRING);

$objForm->setDefaults([
    // Set value of field 'cool text' to 'ValidForm Builder'
    "cool-text" => "ValidForm Builder",
    // Check options 2 and 3
    "cool" => ["option2", "option3"]
]);
Tags
author

Felix Langfeldt [email protected]

author

Robin van Baalen [email protected]

version
5.3.0

Table of Contents

Methods

getAction()  : string
getDefaults()  : array<string|int, mixed>
getDescription()  : string
getDisplayErrors()  : bool
getElements()  : Collection
getJsEvents()  : array<string|int, mixed>
getMainAlert()  : string
getMeta()  : array<string|int, mixed>
getName()  : string
getNoValuesMessage()  : string
getRequiredStyle()  : string
getSubmitLabel()  : string
setAction()  : void
setCachedFields()  : void
setDescription()  : void
setDisplayErrors()  : void
setElements()  : void
setJsEvents()  : void
setMainAlert()  : void
setMeta()  : void
setName()  : void
setNoValuesMessage()  : void
setRequiredStyle()  : void
setSubmitLabel()  : void
setUniqueId()  : void
setUseCsrfProtection()  : void

Methods

getAction()

public getAction() : string

getAction() Returns the value of $__action

Return values
string

getDefaults()

public getDefaults() : array<string|int, mixed>

getDefaults() Returns the value of $__defaults

Return values
array<string|int, mixed>

getDescription()

public getDescription() : string

getDescription() Returns the value of $__description

Return values
string

getDisplayErrors()

public getDisplayErrors() : bool

getDisplayErrors() Returns the value of $__displayerrors

Return values
bool

getJsEvents()

public getJsEvents() : array<string|int, mixed>

getJsEvents() Returns the value of $__jsevents

Return values
array<string|int, mixed>

getMainAlert()

public getMainAlert() : string

getMainAlert() Returns the main alertof this ValidForm instance

Return values
string

getMeta()

public getMeta() : array<string|int, mixed>

getMeta() Returns the value of $__meta

Return values
array<string|int, mixed>

getName()

public getName() : string

getName() Returns the name of this ValidForm instance

Return values
string

getNoValuesMessage()

public getNoValuesMessage() : string

getNoValuesMessage() Returns the value of $__novaluesmessage

Return values
string

getRequiredStyle()

public getRequiredStyle() : string

getRequiredStyle() Returns the value of $__requiredstyle

Return values
string

getSubmitLabel()

public getSubmitLabel() : string

getSubmitLabel() Returns the value of $__submitlabel

Return values
string

setAction()

public setAction() : void

setAction(string $strFormAction) Overwrites the value of $__action

setCachedFields()

public setCachedFields() : void

setCachedFields(Collection $objCollection) Overwrites the value of $__cachedfields. Not recommended for API use*

setDescription()

public setDescription() : void

setDescription(string $strDescription) Overwrites the value of $__description

setDisplayErrors()

public setDisplayErrors() : void

setDisplayErrors(bool $arrJsEvents) Overwrites the value of $__displayerrors. Not recommended* use instead.

setElements()

public setElements() : void

setElements(Collection $objCollection) Overwrites the internal elements collection.

setJsEvents()

public setJsEvents() : void

setJsEvents(array $arrJsEvents) Overwrites the value of $__jsevents.

setMainAlert()

public setMainAlert() : void

setMainAlert(string $strMainAlert) Overwrites the main alert of this ValidForm instance

setMeta()

public setMeta() : void

setMeta(array $arrMeta) Overwrites the value of $__meta

setName()

public setName() : void

setName(string $strName) Overwrites the name of this ValidForm instance

setNoValuesMessage()

public setNoValuesMessage() : void

setNoValuesMessage(string $strNoValuesMessage) Overwrites the value of $__novaluesmessage.

setRequiredStyle()

public setRequiredStyle() : void

setRequiredStyle(string $strRequiredStyle) Overwrites the value of $__requiredstyle.

setSubmitLabel()

public setSubmitLabel() : void

setSubmitLabel(string $strSubmitLabel) Overwrites the value of $__submitlabel

setUniqueId()

public setUniqueId() : void

setUniqueId(string $strUniqueId) Overwrites the value of $__uniqueid.

setUseCsrfProtection()

public setUseCsrfProtection() : void

setUseCsrfProtection(boolean $value) Overwrites the value of $__usecsrfprotection


        
On this page

Search results