class Form (View source)

Base class for forms, loads default configuration options, checks allowed values etc.

Properties

string $name

Form name

string[] $fields

Form fields (paths), filled by readFormPaths(), indexed by field name

array $default

Stores default values for some fields (eg. pmadb tables)

Methods

__construct(string $formName, array $form, ConfigFile $configFile, int|null $index = null)

Reads default config values

string|null
getOptionType(string $optionName)

Returns type of given option

array
getOptionValueList(string $optionPath)

Returns allowed values for select fields

static void
resetGroupCounter()

Reset the group counter, function for testing purposes

void
readFormPaths(array $form)

Reads form paths to $fields

void
readTypes()

Reads fields' types to $this->fieldsTypes

array
cleanGroupPaths(array $form)

Remove slashes from group names

void
loadForm(string $formName, array $form)

Reads form settings and prepares class to work with given subset of config file

Details

__construct(string $formName, array $form, ConfigFile $configFile, int|null $index = null)

Reads default config values

Parameters

string $formName

Form name

array $form

Form data

ConfigFile $configFile

ConfigFile instance

int|null $index

Arbitrary index, doesn't affect class' behavior

string|null getOptionType(string $optionName)

Returns type of given option

Parameters

string $optionName

path or field name

Return Value

string|null

one of: boolean, integer, double, string, select, array

array getOptionValueList(string $optionPath)

Returns allowed values for select fields

Parameters

string $optionPath

Option path

Return Value

array

static void resetGroupCounter()

Reset the group counter, function for testing purposes

Return Value

void

protected void readFormPaths(array $form)

Reads form paths to $fields

Parameters

array $form Form

Return Value

void

protected void readTypes()

Reads fields' types to $this->fieldsTypes

Return Value

void

protected array cleanGroupPaths(array $form)

Remove slashes from group names

Parameters

array $form

The form data

Return Value

array

See also

issue #15836

void loadForm(string $formName, array $form)

Reads form settings and prepares class to work with given subset of config file

Parameters

string $formName

Form name

array $form Form

Return Value

void