FieldsService

Type
Class
Namespace
Craft
Inherits
Craft\FieldsService » Craft\BaseApplicationComponent » CApplicationComponent (opens new window) » CComponent (opens new window)
Implements
IApplicationComponent
Since
1.0

Class FieldsService

See also http://craftcms.com

View source (opens new window)

# Public Properties

Property Description
$behaviors (opens new window) array (opens new window) – The behaviors that should be attached to this component.
$oldFieldColumnPrefix string (opens new window)

# $oldFieldColumnPrefix

Signature

public string $oldFieldColumnPrefix = 'field_'

# Public Methods

Method Description
__call() (opens new window) Calls the named method which is not a class method.
__get() (opens new window) Returns a property value, an event handler list or a behavior based on its name.
__isset() (opens new window) Checks if a property value is null.
__set() (opens new window) Sets value of a component property.
__unset() (opens new window) Sets a component property to be null.
asa() (opens new window) Returns the named behavior object.
assembleLayout() Assembles a field layout.
assembleLayoutFromPost() Assembles a field layout from post data.
attachBehavior() (opens new window) Attaches a behavior to this component.
attachBehaviors() (opens new window) Attaches a list of behaviors to the component.
attachEventHandler() (opens new window) Attaches an event handler to an event.
canGetProperty() (opens new window) Determines whether a property can be read.
canSetProperty() (opens new window) Determines whether a property can be set.
deleteField() Deletes a field.
deleteFieldById() Deletes a field by its ID.
deleteGroupById() Deletes a field group.
deleteLayoutById() Deletes a field layout(s) by its ID.
deleteLayoutsByType() Deletes field layouts of a given type.
detachBehavior() (opens new window) Detaches a behavior from the component.
detachBehaviors() (opens new window) Detaches all behaviors from the component.
detachEventHandler() (opens new window) Detaches an existing event handler.
disableBehavior() (opens new window) Disables an attached behavior.
disableBehaviors() (opens new window) Disables all behaviors attached to this component.
doesFieldWithHandleExist() Returns whether a field exists with a given handle and context.
enableBehavior() (opens new window) Enables an attached behavior.
enableBehaviors() (opens new window) Enables all behaviors attached to this component.
evaluateExpression() (opens new window) Evaluates a PHP expression or callback under the context of this component.
getAllFieldTypes() Returns all installed fieldtypes.
getAllFields() Returns all fields within a field context(s).
getAllGroups() Returns all field groups.
getEventHandlers() (opens new window) Returns the list of attached event handlers for an event.
getFieldByHandle() Returns a field by its handle.
getFieldById() Returns a field by its ID.
getFieldType() Gets a fieldtype.
getFieldsByElementType() Returns all of the fields used by a given element type.
getFieldsByGroupId() Returns all the fields in a given group.
getFieldsWithContent() Returns all fields that have a column in the content table.
getGroupById() Returns a field group by its ID.
getIsInitialized() (opens new window) Checks if this application component has been initialized.
getLayoutById() Returns a field layout by its ID.
getLayoutByType() Returns a field layout by its type.
getLayoutFieldsById() Returns a layout's fields by its ID.
getLayoutTabsById() Returns a layout's tabs by its ID.
getOrderedLayoutFieldsById() Returns a layout's fields by its ID, in the layout-defined sort order.
hasEvent() (opens new window) Determines whether an event is defined.
hasEventHandler() (opens new window) Checks whether the named event has attached handlers.
hasProperty() (opens new window) Determines whether a property is defined.
init() (opens new window) Initializes the application component.
isInitialized() Checks if this application component has been initialized yet, or not.
onSaveFieldLayout() Fires an 'onSaveFieldLayout' event.
populateFieldType() Populates a fieldtype by a field model.
raiseEvent() (opens new window) Raises an event.
saveField() Saves a field.
saveGroup() Saves a field group.
saveLayout() Saves a field layout.
validateField() Validates a field's settings.

# assembleLayout()

Assembles a field layout.

View source (opens new window)

Arguments

Returns

Craft\FieldLayoutModel

Signature

public Craft\FieldLayoutModel assembleLayout ( $postedFieldLayout, $requiredFields = [] )

# assembleLayoutFromPost()

Assembles a field layout from post data.

View source (opens new window)

Arguments

Returns

Craft\FieldLayoutModel

Signature

public Craft\FieldLayoutModel assembleLayoutFromPost ( $namespace = null )

# deleteField()

Signature

public boolean deleteField ( Craft\FieldModel $field )

# deleteFieldById()

Deletes a field by its ID.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

Signature

public boolean deleteFieldById ( $fieldId )

# deleteGroupById()

Signature

public boolean deleteGroupById ( $groupId )

# deleteLayoutById()

Deletes a field layout(s) by its ID.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

Signature

public boolean deleteLayoutById ( $layoutId )

# deleteLayoutsByType()

Deletes field layouts of a given type.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

Signature

public boolean deleteLayoutsByType ( $type )

# doesFieldWithHandleExist()

Returns whether a field exists with a given handle and context.

View source (opens new window)

Arguments

Returns

boolean (opens new window) – Whether a field with that handle exists

Signature

public boolean doesFieldWithHandleExist ( $handle, $context = null )

# getAllFieldTypes()

Returns all installed fieldtypes.

View source (opens new window)

Returns

array (opens new window)

Signature

public array getAllFieldTypes ( )

# getAllFields()

Returns all fields within a field context(s).

View source (opens new window)

Arguments

Returns

Craft\FieldModel[] – The resulting fields

Signature

public Craft\FieldModel[] getAllFields ( $indexBy = null, $context = null )

# getAllGroups()

Signature

public array getAllGroups ( $indexBy = null )

# getFieldByHandle()

Returns a field by its handle.

View source (opens new window)

Arguments

Returns

Craft\FieldModel, null (opens new window)

Signature

public Craft\FieldModel, null getFieldByHandle ( $handle )

# getFieldById()

Signature

public Craft\FieldModel, null getFieldById ( $fieldId )

# getFieldType()

Signature

public Craft\BaseFieldType, null getFieldType ( $class )

# getFieldsByElementType()

Returns all of the fields used by a given element type.

View source (opens new window)

Arguments

Returns

Craft\FieldModel[]

Signature

public Craft\FieldModel[] getFieldsByElementType ( $elementTypeClass, $indexBy = null )

# getFieldsByGroupId()

Returns all the fields in a given group.

View source (opens new window)

Arguments

Returns

array (opens new window)

Signature

public array getFieldsByGroupId ( $groupId, $indexBy = null )

# getFieldsWithContent()

Returns all fields that have a column in the content table.

View source (opens new window)

Returns

array (opens new window)

Signature

public array getFieldsWithContent ( )

# getGroupById()

Signature

public Craft\FieldGroupModel, null getGroupById ( $groupId )

# getLayoutById()

Returns a field layout by its ID.

View source (opens new window)

Arguments

Returns

Craft\FieldLayoutModel, null (opens new window)

Signature

public Craft\FieldLayoutModel, null getLayoutById ( $layoutId )

# getLayoutByType()

Returns a field layout by its type.

View source (opens new window)

Arguments

Returns

Craft\FieldLayoutModel

Signature

public Craft\FieldLayoutModel getLayoutByType ( $type )

# getLayoutFieldsById()

Returns a layout's fields by its ID.

View source (opens new window)

Arguments

Returns

array (opens new window)

Signature

public array getLayoutFieldsById ( $layoutId )

# getLayoutTabsById()

Returns a layout's tabs by its ID.

View source (opens new window)

Arguments

Returns

array (opens new window)

Signature

public array getLayoutTabsById ( $layoutId )

# getOrderedLayoutFieldsById()

Returns a layout's fields by its ID, in the layout-defined sort order.

View source (opens new window)

Arguments

Returns

array (opens new window)

Signature

public array getOrderedLayoutFieldsById ( $layoutId )

# onSaveFieldLayout()

Fires an 'onSaveFieldLayout' event.

View source (opens new window)

Arguments

Returns

null (opens new window)

Signature

public null onSaveFieldLayout ( Craft\Event $event )

# populateFieldType()

Signature

public Craft\BaseFieldType, null populateFieldType ( Craft\FieldModel $field, $element = null )

# saveField()

Signature

public boolean saveField ( Craft\FieldModel $field, $validate = true )

# saveGroup()

Signature

public boolean saveGroup ( Craft\FieldGroupModel $group )

# saveLayout()

Saves a field layout.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

Signature

public boolean saveLayout ( Craft\FieldLayoutModel $layout )

# validateField()

Validates a field's settings.

View source (opens new window)

Arguments

Returns

boolean (opens new window)

Signature

public boolean validateField ( Craft\FieldModel $field )