Blesta
  • Package
  • Class
  • Tree
  • Deprecated

Packages

  • blesta
    • app
      • controllers
      • models
    • components
      • areyouahuman
      • auth
        • motp
        • oath
      • delivery
        • interfax
        • postal
          • methods
      • download
      • email
      • events
        • default
      • exchange
        • rates
          • google
            • finance
          • yahoo
            • finance
      • gateway
        • payments
      • gateways
      • invoice
        • delivery
        • templates
          • quickbooks
            • invoice
      • json
      • modules
      • net
        • amazon
          • s3
        • http
        • net
          • geo
            • ip
      • plugins
      • recaptcha
      • reports
        • aging
          • invoices
        • custom
          • report
        • invoice
          • creation
        • tax
          • liability
        • transactions
          • applied
          • received
      • security
      • session
        • cart
      • settingscollection
      • upgrades
        • tasks
      • upload
      • vcard
    • helpers
      • currency
        • format
      • data
        • structure
          • array
          • string
      • text
        • parser
      • widget
        • client
  • minPHP
    • components
      • input
      • record
    • helpers
      • color
      • data
        • structure
      • date
      • form
      • html
      • javascript
      • xml
    • lib
  • None
  • PHP

Classes

  • Form

Class Form

Form helper, requires Html helper

Allow the creation of forms and their respective fields and attributes

Html
Extended by Form
Package: minPHP\helpers\form
Located at helpers/form/form.php

Methods summary

public
# setCsrfOptions( array $options )

Sets the CSRF Token options

Sets the CSRF Token options

Parameters

$options
array
$options An array of CSRF token options including: - token_name The field name of the CSRF token - set_on_create True to automatically set the CSRF token on create - token_key The CSRF token key used to make each token unique
public
# setEol( string $eol )

Sets the end of line character to use

Sets the end of line character to use

Parameters

$eol
string
$eol The end of line character to use
public
# setOutput( boolean $return )

Set whether to return $output generated by these methods, or to echo it out instead

Set whether to return $output generated by these methods, or to echo it out instead

Parameters

$return
boolean
$return True to return output from these form methods, false to echo results instead
public array
# collapseObjectArray( array $obj_arr, mixed $value_var, string $key_var = null, string $glue = null )

Collapses an object array down to a simple key/value array or numerically indexed array whose values are member variables of the given object array

Collapses an object array down to a simple key/value array or numerically indexed array whose values are member variables of the given object array

Parameters

$obj_arr
array
$obj_arr The object array to collapse
$value_var
mixed
$value_var A string representing the name of the member variable, or an array of member variable values to concatenate
$key_var
string
$key_var The name of the member variable to use as the key in the array, null for numerically indexed array
$glue
string
$glue The value to use to concat multiple $value_var values together, if null, will simply print only the first non-null value in $value_var

Returns

array
An array in key/value form
public string
# create( string $uri = null, array $attributes = array() )

Begins a new form. Default method='post', but $attributes may overwrite that.

Begins a new form. Default method='post', but $attributes may overwrite that.

Parameters

$uri
string
$uri The $uri for the form to post to, defaults to $_SERVER['REQUEST_URI']
$attributes
array
$attributes The attributes and values to add in the <form> tag, in key=value pairs

Returns

string
The HTML for the <form> tag, void if output enabled
public string
# end( string $end_str = null )

Ends a form, appends an optional $end_str

Ends a form, appends an optional $end_str

Parameters

$end_str
string
$end_str The string to add after the </form> tag

Returns

string
The </form> tag, void if output enabled
public string
# getCsrfToken( string $key = null )

Generates a CSRF token

Generates a CSRF token

Parameters

$key
string
$key The key used to generate the CSRF token

Returns

string
The computed CSRF token
public boolean
# verifyCsrfToken( string $key = null, string $csrf_token = null )

Verifies that the given CSRF token is valid

Verifies that the given CSRF token is valid

Parameters

$key
string
$key The key used to generate the original CSRF token
$csrf_token
string
$csrf_token The given CSRF token, null to automatically pull the CSRF token from the $_POST data

Returns

boolean
True if the token is valid, false otherwise
public string
# fields( array $fields )

Allows fields to be created from an array of fields.

Allows fields to be created from an array of fields.

Parameters

$fields
array
$fields An array of fields to set

Returns

string
The fields given, void if output enabled
public string
# label( string $name, string $for = null, array $attributes = null, boolean $preserve_tags = false )

Creates a label with the given name and marks it for the given field

Creates a label with the given name and marks it for the given field

Parameters

$name
string
$name The name of this label
$for
string
$for The ID of the form element this label is part of
$attributes
array
$attributes Attributes for this label
$preserve_tags
boolean
$preserve_tags True to preserve tags in the label name

Returns

string
The label specified, void if output enabled
public string
# fieldText( string $name, string $value = null, array $attributes = array() )

Creates a text input field

Creates a text input field

Parameters

$name
string
$name The name to set in the HTML name field
$value
string
$value The value to set in the HTML value field
$attributes
array
$attributes Attributes for this input field

Returns

string
The text field specified, void if output enabled
public string
# fieldHidden( string $name, string $value = null, array $attributes = array() )

Creates a hidden input field

Creates a hidden input field

Parameters

$name
string
$name The name to set in the HTML name field
$value
string
$value The value to set in the HTML value field
$attributes
array
$attributes Attributes for this input field

Returns

string
The hidden field specified, void if output enabled
public string
# fieldImage( string $name, string $value = null, array $attributes = array() )

Creates an image input field

Creates an image input field

Parameters

$name
string
$name The name to set in the HTML name field
$value
string
$value The value to set in the HTML value field
$attributes
array
$attributes Attributes for this input field

Returns

string
The image field specified, void if output enabled
public string
# fieldReset( string $name, string $value = null, array $attributes = array() )

Creates a reset input field

Creates a reset input field

Parameters

$name
string
$name The name to set in the HTML name field
$value
string
$value The value to set in the HTML value field
$attributes
array
$attributes Attributes for this input field

Returns

string
The reset field specified, void if output enabled
public string
# fieldCheckbox( string $name, string $value = null, boolean $checked = false, array $attributes = array() )

Creates a checkbox

Creates a checkbox

Parameters

$name
string
$name The name to set in the HTML name field
$value
string
$value The value to set in the HTML value field
$checked
boolean
$checked True to set this field as checked
$attributes
array
$attributes Attributes for this input field

Returns

string
The checkbox field specified, void if output enabled
public string
# fieldRadio( string $name, string $value = null, boolean $checked = false, array $attributes = array() )

Creates a radio box

Creates a radio box

Parameters

$name
string
$name The name to set in the HTML name field
$value
string
$value The value to set in the HTML value field
$checked
boolean
$checked True to set this field as checked
$attributes
array
$attributes Attributes for this input field

Returns

string
The radio field specified, void if output enabled
public string
# fieldTextarea( string $name, string $value = null, array $attributes = array() )

Creates a textarea field

Creates a textarea field

Parameters

$name
string
$name The name to set in the HTML name field
$value
string
$value The value to set in this textarea
$attributes
array
$attributes Attributes for this input field

Returns

string
The textarea field, void if output enabled
public string
# fieldPassword( string $name, array $attributes = array() )

Creates a password input field

Creates a password input field

Parameters

$name
string
$name The name to set in the HTML name field
$attributes
array
$attributes Attributes for this input field

Returns

string
The password field, void if output enabled
public string
# fieldFile( string $name, array $attributes = array() )

Creates a file input field

Creates a file input field

Parameters

$name
string
$name The name to set in the HTML name field
$attributes
array
$attributes Attributes for this input field

Returns

string
The file field, void if output enabled
public string
# fieldSelect( string $name, array $options = array(), mixed $selected_value = null, array $attributes = array(), array $option_attributes = array() )

Creates a select list

Creates a select list

Parameters

$name
string
$name The name to set in the HTML name field
$options
array
$options The options to place in this select list
$selected_value
mixed
$selected_value The option(s) to set as selected
$attributes
array
$attributes Attributes for this input field
$option_attributes
array
$option_attributes Attributes for each option to set. If single dimension will set the attributes for every option, if multi-dimensional will set option for each element key that matches in $options

Returns

string
The select field, void if output enabled
public string
# fieldMultiSelect( string $name, array $options = array(), string $selected_values = array(), array $attributes = array(), array $option_attributes = array() )

Creates a select list with multiple selectable options

Creates a select list with multiple selectable options

Parameters

$name
string
$name The name to set in the HTML name field
$options
array
$options The options to place in this select list
$selected_values
string
$selected_value The option to set as selected
$attributes
array
$attributes Attributes for this input field
$option_attributes
array
$option_attributes Attributes for each option to set. If single dimension will set the attributes for every option, if multi-dimensional will set option for each element key that matches in $options

Returns

string
The multi-select field, void if output enabled
public string
# fieldButton( string $name, string $value = null, array $attributes = array() )

Creates a button with default type=button, can be overriden by attirbutes

Creates a button with default type=button, can be overriden by attirbutes

Parameters

$name
string
$name The name to set in the HTML name field
$value
string
$value The value to set in the HTML value field
$attributes
array
$attributes Attributes for this input field

Returns

string
The button field, void if output enabled
public string
# fieldSubmit( string $name, string $value = null, array $attributes = array() )

Creates a button of type submit

Creates a button of type submit

Parameters

$name
string
$name The name to set in the HTML name field
$value
string
$value The value to set in the HTML value field
$attributes
array
$attributes Attributes for this input field

Returns

string
The submit field, void if output enabled

Methods inherited from Html

_(), addCondition(), buildAttributes(), concat(), hyperlink(), ifSet(), isUtf8(), safe()

Magic methods summary

Properties summary

Properties inherited from Html

$xhtml

Blesta API documentation generated by ApiGen 2.8.0