Field Parameters - Richard1320/php-form-processor GitHub Wiki

Each field is its own object in the form, with its own set of parameters. These have to be passed to the form object at initialization as a multi-dimensional array.

$fields = array();

$fields['name'] = array(
	'label'    => 'Name',
	'type'     => 'text',
	'required' => true,
	'name'     => 'name',
);

$fields['email'] = array(
	'label'    => 'Email',
	'type'     => 'email',
	'required' => true,
	'name'     => 'email',
);

$fields['body'] = array(
	'label'    => 'Message',
	'type'     => 'textarea',
	'required' => true,
	'name'     => 'body',
);

Current Core Class Tree

Everything extends from the fieldBase class.

fieldBase

Extends: N/A

Field Types: N/A

Template: N/A

Parameter Accepted Values Default Functionality Notes
name string empty Name attribute of field
required boolean false Require data for field
label string empty Label for field
classes array empty Array of classes to add to the wrapper div
f_classes array empty Array of classes to add to the input element
attributes array empty Extra attributes to add to the input element Array item key is the attribute name. Array item value is the attribute value.
default_value string or array empty Default value of field Form submissions are saved in the $_SESSION superglobal in case of errors. You can loop those previous values to set as default.
description string empty Helpful description text that displays beside the field
multiple boolean false Allow multiple values for submission For input elements, the length of default value array is the number of input elements displayed.
type text select, textarea, or any of the input types

fieldTextarea

Extends: fieldBase

Field Types: textarea

Template: textarea.tpl.php

fieldInputText

Extends: fieldBase

Field Types: text, email, password, anything <input> that is not file, radio, checkbox, or submit

Template: input_text.tpl.php

Parameter Accepted Values Default Functionality Notes
maxlength integer false Maximum number of characters in submitted value

fieldInputFile

Extends: fieldBase

Field Types: file

Template: input_file.tpl.php

Parameter Accepted Values Default Functionality Notes
maxsize integer 8388608 (8MB) Max filesize of uploaded file This amount is in bytes. 1MB = 1048600 bytes.
allowed_extensions array false Allowed file extensions This only checks the extension. Not sufficient for security without additional checks.

fieldInputFileImage

Extends: fieldInputFile

Field Types: file

Template: N/A (Inherit)

fieldOptionsList

Extends: fieldBase

Field Types: N/A

Template: N/A

Parameter Accepted Values Default Functionality Notes
deep array false Array of values for pre-built list The array key is the field value. The array value is the field label.

fieldSelect

Extends: fieldOptionsList

Field Types: select

Template: select.tpl.php

fieldInputRadioCheckbox

Extends: fieldOptionsList

Field Types: radio, checkbox

Template: input_radio_checkbox.tpl.php

⚠️ **GitHub.com Fallback** ⚠️