class FormSetupItem (View source)

This class help to create item for class formSetup

Properties

DoliDB $db
Translate $langs
int $entity
Form $form
string $confKey
string|false $nameText
string $helpText
string $picto
?string $fieldValue
?string $defaultFieldValue
array{name?: string, id?: string, value?: mixed, class?: string, disabled?: ?int<0, 1>, type?: string, size?: int, placeholder?: string, step?: float|string, min?: int, max?: int} $fieldAttr
bool|string $fieldOverride
bool|string $fieldInputOverride
bool|string $fieldOutputOverride
int $rank
array<string, string|array{id: int|string, label: string, color: string, picto: string, labelhtml: string}> $fieldOptions
array<string, string|int|array{id: int|string, label: string, color: string, picto: string, labelhtml: string}> $fieldParams
callable $saveCallBack
callable $setValueFromPostCallBack
string[] $errors
protected string $type

TODO each type must have setAs{type} method to help configuration And set var as protected when its done configuration must be done by method this is important for retrocompatibility of future versions

int<0, 1> $enabled
string $cssClass

Methods

__construct(string $confKey)

Constructor

bool
loadValueFromConf()

load conf value from databases

bool
reloadValueFromConf() deprecated

Reload conf value from databases is an alias of loadValueFromConf

int
saveConfValue()

Save const value based on htdocs/core/actions_setmoduleoptions.inc.php

void
setSaveCallBack(callable $callBack)

Set an override function for saving data

void
setValueFromPostCallBack(callable $callBack)

Set an override function for get data from post

int
setValueFromPost()

Save const value based on htdocs/core/actions_setmoduleoptions.inc.php

int|string
getHelpText()

Get help text or generate it

false|int|string
getNameText()

Get field name text or generate it

bool|string
generateInputField()

generate input field

string
generateInputFieldText()

Generate default input field

string
generateInputFieldPrice()

Generate default input field

string
generateInputFieldEmail()

Generate default input field

string
generateInputFieldUrl()

Generate default input field

string
generateInputFieldTextarea()

generate input field for textarea

string
generateInputFieldHtml()

generate input field for html

string
generateInputFieldCategories()

generate input field for categories

string
generateInputFieldEmailTemplate()

generate input field for email template selector

string
generateInputFieldSecureKey()

generate input field for secure key

string
generateInputFieldPassword(string $type = 'generic', int $defaultmin = 6, int $defaultmax = 50)

generate input field for a password

string
generateInputFieldMultiSelect()

generateInputFieldMultiSelect

string
generateInputFieldSelect()

generateInputFieldSelect

string
generateInputFieldRadio()

generateInputFieldSelect

string
generateInputFieldSelectUser()

No description

string
getType()

get the type : used for old module builder setup conf style conversion and tests because this two class will quickly evolve it's important to not set or get directly $this->type (will be protected) so this method exist to be sure we can manage evolution easily

bool
setTypeFromTypeString(string $type) deprecated

set the type from string : used for old module builder setup conf style conversion and tests because this two class will quickly evolve it's important to not set directly $this->type (will be protected) so this method exist to be sure we can manage evolution easily

null
setErrors(string[]|string $errors)

Add error

bool|string
generateOutputField()

generateOutputField

string
generateOutputFieldMultiSelect()

generateOutputFieldMultiSelect

string
generateOutputFieldColor()

generateOutputFieldColor

string
generateInputFieldColor()

generateInputFieldColor

string
generateOutputFieldSelect()

generateOutputFieldSelect

string
generateOutputFieldSelectUser()

generateOutputFieldSelectUser

setAsString()

Set type of input as string

setAsNumber(int $min = null, int $max = null, int $step = null)

Set type of input as number

setAsEmail()

Set type of input as string

setAsUrl()

Set type of input as string

setAsColor()

Set type of input as color

setAsTextarea()

Set type of input as textarea

setAsHtml()

Set type of input as html editor

setAsEmailTemplate(string $templateType)

Set type of input as emailtemplate selector

setAsThirdpartyType()

Set type of input as thirdparty_type selector

setAsYesNo()

Set type of input as Yes

setAsSecureKey()

Set type of input as secure key

setAsProduct()

Set type of input as product

setAsPrice()

Set type of input as product

setAsCategory(string $catType)

Set type of input as a category selector TODO add default value

setAsTitle()

Set type of input as a simple title. No data to store

setAsMultiSelect(array<string, string|array{id: string, label: string, color: string, picto: string, labelhtml: string}> $fieldOptions)

Set type of input as a simple title. No data to store

setAsSelect(?array<string, string|array{id: string, label: string, color: string, picto: string, labelhtml: string}> $fieldOptions)

Set type of input as a simple title. No data to store

setAsRadio(?array<string, string|array{id: string, label: string, picto?: string, labelIsHtml?: bool}> $fieldOptions)

Set type of input as a simple title. No data to store

setAsSelectUser()

Set type of input as a simple title. No data to store

setAsSelectBankAccount()

Set type of input as a simple title. No data to store

setAsPassword()

Set type of input as a password with dolibarr password rules apply.

setAsGenericPassword()

Set type of input as a generic password without dolibarr password rules (for external passwords for example).

Details

__construct(string $confKey)

Constructor

Parameters

string $confKey

the conf key used in database

bool loadValueFromConf()

load conf value from databases

Return Value

bool

bool reloadValueFromConf() deprecated

deprecated

Reload conf value from databases is an alias of loadValueFromConf

Return Value

bool

int saveConfValue()

Save const value based on htdocs/core/actions_setmoduleoptions.inc.php

Return Value

int

-1 if KO, 1 if OK

void setSaveCallBack(callable $callBack)

Set an override function for saving data

Parameters

callable $callBack

a callable function

Return Value

void

void setValueFromPostCallBack(callable $callBack)

Set an override function for get data from post

Parameters

callable $callBack

a callable function

Return Value

void

int setValueFromPost()

Save const value based on htdocs/core/actions_setmoduleoptions.inc.php

Return Value

int

-1 if KO, 0 nothing to do , 1 if OK

int|string getHelpText()

Get help text or generate it

Return Value

int|string

false|int|string getNameText()

Get field name text or generate it

Return Value

false|int|string

bool|string generateInputField()

generate input field

Return Value

bool|string

string generateInputFieldText()

Generate default input field

Return Value

string

string generateInputFieldPrice()

Generate default input field

Return Value

string

string generateInputFieldEmail()

Generate default input field

Return Value

string

string generateInputFieldUrl()

Generate default input field

Return Value

string

string generateInputFieldTextarea()

generate input field for textarea

Return Value

string

string generateInputFieldHtml()

generate input field for html

Return Value

string

string generateInputFieldCategories()

generate input field for categories

Return Value

string

string generateInputFieldEmailTemplate()

generate input field for email template selector

Return Value

string

string generateInputFieldSecureKey()

generate input field for secure key

Return Value

string

string generateInputFieldPassword(string $type = 'generic', int $defaultmin = 6, int $defaultmax = 50)

generate input field for a password

Parameters

string $type

'dolibarr' (dolibarr password rules apply) or 'generic'

int $defaultmin

Min nb of chars

int $defaultmax

Max nb of chars

Return Value

string

string generateInputFieldMultiSelect()

generateInputFieldMultiSelect

Return Value

string

string generateInputFieldSelect()

generateInputFieldSelect

Return Value

string

string generateInputFieldRadio()

generateInputFieldSelect

Return Value

string

string generateInputFieldSelectUser()

No description

Return Value

string

string getType()

get the type : used for old module builder setup conf style conversion and tests because this two class will quickly evolve it's important to not set or get directly $this->type (will be protected) so this method exist to be sure we can manage evolution easily

Return Value

string

bool setTypeFromTypeString(string $type) deprecated

deprecated this setTypeFromTypeString came deprecated because it exists only for manage setup conversion

set the type from string : used for old module builder setup conf style conversion and tests because this two class will quickly evolve it's important to not set directly $this->type (will be protected) so this method exist to be sure we can manage evolution easily

Parameters

string $type

Possible values based on old module builder setup : 'string', 'textarea', 'category:'.Categorie::TYPE_CUSTOMER', 'emailtemplate', 'thirdparty_type'

Return Value

bool

null setErrors(string[]|string $errors)

Add error

Parameters

string[]|string $errors

the error text

Return Value

null

bool|string generateOutputField()

generateOutputField

Return Value

bool|string

Generate the output html for this item

string generateOutputFieldMultiSelect()

generateOutputFieldMultiSelect

Return Value

string

string generateOutputFieldColor()

generateOutputFieldColor

Return Value

string

string generateInputFieldColor()

generateInputFieldColor

Return Value

string

string generateOutputFieldSelect()

generateOutputFieldSelect

Return Value

string

string generateOutputFieldSelectUser()

generateOutputFieldSelectUser

Return Value

string

FormSetupItem setAsString()

Set type of input as string

Return Value

FormSetupItem

FormSetupItem setAsNumber(int $min = null, int $max = null, int $step = null)

Set type of input as number

Parameters

int $min

minimum value for input number

int $max

maximum value for input number

int $step

legal number intervals

Return Value

FormSetupItem

FormSetupItem setAsEmail()

Set type of input as string

Return Value

FormSetupItem

FormSetupItem setAsUrl()

Set type of input as string

Return Value

FormSetupItem

FormSetupItem setAsColor()

Set type of input as color

Return Value

FormSetupItem

FormSetupItem setAsTextarea()

Set type of input as textarea

Return Value

FormSetupItem

FormSetupItem setAsHtml()

Set type of input as html editor

Return Value

FormSetupItem

FormSetupItem setAsEmailTemplate(string $templateType)

Set type of input as emailtemplate selector

Parameters

string $templateType

email template type

Return Value

FormSetupItem

FormSetupItem setAsThirdpartyType()

Set type of input as thirdparty_type selector

Return Value

FormSetupItem

FormSetupItem setAsYesNo()

Set type of input as Yes

Return Value

FormSetupItem

FormSetupItem setAsSecureKey()

Set type of input as secure key

Return Value

FormSetupItem

FormSetupItem setAsProduct()

Set type of input as product

Return Value

FormSetupItem

FormSetupItem setAsPrice()

Set type of input as product

Return Value

FormSetupItem

FormSetupItem setAsCategory(string $catType)

Set type of input as a category selector TODO add default value

Parameters

string $catType

Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode (0, 1, 2, ...) is deprecated.

Return Value

FormSetupItem

FormSetupItem setAsTitle()

Set type of input as a simple title. No data to store

Return Value

FormSetupItem

FormSetupItem setAsMultiSelect(array<string, string|array{id: string, label: string, color: string, picto: string, labelhtml: string}> $fieldOptions)

Set type of input as a simple title. No data to store

Parameters

array<string, string|array{id: string, label: string, color: string, picto: string, labelhtml: string}> $fieldOptions

A table of field options

Return Value

FormSetupItem

FormSetupItem setAsSelect(?array<string, string|array{id: string, label: string, color: string, picto: string, labelhtml: string}> $fieldOptions)

Set type of input as a simple title. No data to store

Parameters

?array<string, string|array{id: string, label: string, color: string, picto: string, labelhtml: string}> $fieldOptions

A table of field options

Return Value

FormSetupItem

FormSetupItem setAsRadio(?array<string, string|array{id: string, label: string, picto?: string, labelIsHtml?: bool}> $fieldOptions)

Set type of input as a simple title. No data to store

Parameters

?array<string, string|array{id: string, label: string, picto?: string, labelIsHtml?: bool}> $fieldOptions

A table of field options

Return Value

FormSetupItem

FormSetupItem setAsSelectUser()

Set type of input as a simple title. No data to store

Return Value

FormSetupItem

FormSetupItem setAsSelectBankAccount()

Set type of input as a simple title. No data to store

Return Value

FormSetupItem

FormSetupItem setAsPassword()

Set type of input as a password with dolibarr password rules apply.

Hide entry on display.

Return Value

FormSetupItem

See also

setAsGenericPassword()

FormSetupItem setAsGenericPassword()

Set type of input as a generic password without dolibarr password rules (for external passwords for example).

Hide entry on display.

Return Value

FormSetupItem

See also

setAsPassword()