Form
class Form (View source)
Helpful functions for working with forms. Includes HTML input tags and the like.
\@package Helpers
Properties
protected int | $radioIndex | Internal counter used to generate unique IDs for radio inputs with the same name. |
|
protected int | $selectIndex | Internal counter used to generate unique IDs for select inputs with the same name. |
|
protected Application | $app | The Application instance. |
|
protected Text | $th | The text service instance. |
|
protected Arrays | $ah | Arrays helper instance. |
Methods
Returns an action suitable for including in a form action property.
Creates a submit button.
Creates a button.
Creates a label tag.
Creates a file input element.
Creates a hidden form field.
Generates a checkbox.
Creates a textarea field.
Generates a radio button.
Checks the request (first POST then GET) based on the key passed.
Renders a text input field.
Renders a number input field.
Renders an email input field.
Renders a telephone input field.
Renders a URL input field.
Renders a search input field.
Renders a select field.
Renders a select menu to choose a Country.
Renders a multiple select box.
Renders a password input field.
Generates HTML code that can be added at the beginning of a form to disable username/password autocompletion.
Checks the request based on the key passed.
Internal function that creates an element of type $type. Handles the messiness of evaluating $valueOrMiscFields. Assigns a default class of ccm-input-$type.
Create an HTML fragment of attribute values, merging any CSS class names as necessary.
Details
__construct(Application $app)
Initialize the instance.
action(string $action, string $task = null)
Returns an action suitable for including in a form action property.
string
submit(string $key, string $value, array $miscFields = [], string $additionalClasses = '')
Creates a submit button.
string
button(string $key, string $value, array $miscFields = [], string $additionalClasses = '')
Creates a button.
string
label(string $forFieldID, string $innerHTML, array $miscFields = [])
Creates a label tag.
string
file(string $key, array $miscFields = [])
Creates a file input element.
string
hidden(string $key, string $value = null, array $miscFields = [])
Creates a hidden form field.
string
checkbox(string $key, string $value, string $isChecked = false, array $miscFields = [])
Generates a checkbox.
string
textarea(string $key, string|array $valueOrMiscFields = '', array $miscFields = [])
Creates a textarea field.
string
radio(string $key, string $value, string|array $checkedValueOrMiscFields = '', array $miscFields = [])
Generates a radio button.
false|array|string
getRequestValue(string $key)
Checks the request (first POST then GET) based on the key passed.
If $key denotes an array (eg akID[34]['value']) we'll turn the key into arrays if the key has text versions of [ and ] in it If the result is a string, it'll be escaped (with htmlspecialchars).
string
text(string $key, string|array $valueOrMiscFields = '', array $miscFields = [])
Renders a text input field.
string
number(string $key, string|array $valueOrMiscFields = '', array $miscFields = [])
Renders a number input field.
string
email(string $key, string|array $valueOrMiscFields = '', array $miscFields = [])
Renders an email input field.
string
telephone(string $key, string|array $valueOrMiscFields = '', array $miscFields = [])
Renders a telephone input field.
string
url(string $key, string|array $valueOrMiscFields = '', array $miscFields = [])
Renders a URL input field.
string
search(string $key, string|array $valueOrMiscFields = '', array $miscFields = [])
Renders a search input field.
select(string $key, array $optionValues, string|array $valueOrMiscFields = '', array $miscFields = [])
Renders a select field.
selectCountry(string $key, string $selectedCountryCode = '', array $configuration = [], array $miscFields = [])
Renders a select menu to choose a Country.
selectMultiple(string $key, array $optionValues, array|string $defaultValues = false, array $miscFields = [])
Renders a multiple select box.
string
password(string $key, string|array $valueOrMiscFields = '', array $miscFields = [])
Renders a password input field.
string
getAutocompletionDisabler()
Generates HTML code that can be added at the beginning of a form to disable username/password autocompletion.
protected false|array|string
processRequestValue(string $key, string $type = 'post')
Checks the request based on the key passed.
If $key denotes an array (eg akID[34]['value']) we'll turn the key into arrays if the key has text versions of [ and ] in it If the result is a string, it'll be escaped (with htmlspecialchars).
protected string
inputType(string $key, string $type, string|array $valueOrMiscFields, array $miscFields)
Internal function that creates an element of type $type. Handles the messiness of evaluating $valueOrMiscFields. Assigns a default class of ccm-input-$type.
protected string
parseMiscFields(string $defaultClass, array $attributes)
Create an HTML fragment of attribute values, merging any CSS class names as necessary.