Class humhub\modules\user\models\fieldtype\BaseType

Inheritancehumhub\modules\user\models\fieldtype\BaseType » yii\base\Model
Subclasseshumhub\modules\user\models\fieldtype\Birthday, humhub\modules\user\models\fieldtype\Checkbox, humhub\modules\user\models\fieldtype\CheckboxList, humhub\modules\user\models\fieldtype\CountrySelect, humhub\modules\user\models\fieldtype\Date, humhub\modules\user\models\fieldtype\DateTime, humhub\modules\user\models\fieldtype\MarkdownEditor, humhub\modules\user\models\fieldtype\Number, humhub\modules\user\models\fieldtype\Select, humhub\modules\user\models\fieldtype\Text, humhub\modules\user\models\fieldtype\TextArea
Available since version0.5

ProfileFieldType is the base class for all Profile Field Types.

Public Methods

Hide inherited methods

MethodDescriptionDefined By
addFieldType() Add new FieldType to stack humhub\modules\user\models\fieldtype\BaseType
addToProfileTable() Adds the new profile type to the profile table. humhub\modules\user\models\fieldtype\BaseType
beforeProfileSave() This method is called before the field value is stored in Profile table. humhub\modules\user\models\fieldtype\BaseType
delete() Deletes a Profile Field Type humhub\modules\user\models\fieldtype\BaseType
getFieldFormDefinition() Return the Form Element to edit the value of the Field humhub\modules\user\models\fieldtype\BaseType
getFieldRules() Returns validation rules for field type. humhub\modules\user\models\fieldtype\BaseType
getFieldTypes() Returns a list of all available field type classes. humhub\modules\user\models\fieldtype\BaseType
getFormDefinition() Returns the Edit Form for administrators this Field Type. humhub\modules\user\models\fieldtype\BaseType
getLabels() Return array of Labels for Field humhub\modules\user\models\fieldtype\BaseType
getTypeInstances() Returns an array of instances of all available field types. humhub\modules\user\models\fieldtype\BaseType
getUserValue() Returns the value of a given user of this field humhub\modules\user\models\fieldtype\BaseType
loadDefaults() Load field type default settings to the profile humhub\modules\user\models\fieldtype\BaseType
loadFieldConfig() Loads the profile field type settings humhub\modules\user\models\fieldtype\BaseType
save() Saves the profile field type humhub\modules\user\models\fieldtype\BaseType
setProfileField() Links a ProfileField to the ProfileFieldType. humhub\modules\user\models\fieldtype\BaseType
validate() Validates a ProfileFieldType humhub\modules\user\models\fieldtype\BaseType

Property Details

$fieldTypes public property
public array $fieldTypes = []
$profileField public property

Method Details

addFieldType() public method

Add new FieldType to stack

public void addFieldType ( $fieldClass, $title )
$fieldClass string
$title string
addToProfileTable() public method

Adds the new profile type to the profile table.

This method should be overwritten by the child class.

public boolean addToProfileTable ( )
beforeProfileSave() public method

This method is called before the field value is stored in Profile table.

public string|null beforeProfileSave ( $value )
$value string
return string|null

Modified value

delete() public method

Deletes a Profile Field Type

public void delete ( )
throws \yii\db\Exception
getFieldFormDefinition() public method

Return the Form Element to edit the value of the Field

public array getFieldFormDefinition ( )
getFieldRules() public method

Returns validation rules for field type.

The inherited field type class should pass his rules to this method.

public array getFieldRules ( $rules = [] )
$rules array
return array

Rules

getFieldTypes() public method

Returns a list of all available field type classes.

public array getFieldTypes ( )
getFormDefinition() public method

Returns the Edit Form for administrators this Field Type.

This method should be overwritten by the file type class.

public array getFormDefinition ( $definition = [] )
$definition array
return array

Of Form Definition

getLabels() public method

Return array of Labels for Field

public array getLabels ( )
getTypeInstances() public method

Returns an array of instances of all available field types.

public array getTypeInstances ( $profileField null )
$profileField humhub\modules\user\models\ProfileField|null
throws \yii\base\Exception
getUserValue() public method

Returns the value of a given user of this field

public string getUserValue ( $user, $raw true )
$user humhub\modules\user\models\User
$raw boolean
loadDefaults() public method

Load field type default settings to the profile

public void loadDefaults ( humhub\modules\user\models\Profile $profile )
$profile humhub\modules\user\models\Profile
loadFieldConfig() public method

Loads the profile field type settings

These settings are loaded from the underlying ProfileField.

public void loadFieldConfig ( )
save() public method

Saves the profile field type

The settings/configuration for a ProfileFieldType are saved in ProfileField in attribute "field_type_config" as JSON data.

The ProfileFieldType Class itself can overwrite this behavior.

public void save ( )
throws \yii\base\Exception
setProfileField() public method

Links a ProfileField to the ProfileFieldType.

public void setProfileField ( $profileField )
$profileField humhub\modules\user\models\ProfileField
validate() public method

Validates a ProfileFieldType

This is only necessary when its linked to a profileField and the profiletype has the current type of profilefieldtype

public boolean validate ( $attributes null, $clearErrors true )
$attributes humhub\modules\user\models\ProfileField|null
$clearErrors boolean