Skip to content

FieldConditionRuleTrait

Type
Trait
Namespace
craft\fields\conditions
Implemented by
craft\fields\conditions\CountryFieldConditionRule, craft\fields\conditions\DateFieldConditionRule, craft\fields\conditions\EmptyFieldConditionRule, craft\fields\conditions\LightswitchFieldConditionRule, craft\fields\conditions\MoneyFieldConditionRule, craft\fields\conditions\NumberFieldConditionRule, craft\fields\conditions\OptionsFieldConditionRule, craft\fields\conditions\RelationalFieldConditionRule, craft\fields\conditions\TextFieldConditionRule
Since
4.0.0

FieldConditionRuleTrait implements the common methods and properties for custom fields’ query condition rule classes.

View source

Public Properties

PropertyDescription
conditioncraft\elements\conditions\ElementConditionInterface
fieldUidstring – The UUID of the custom field associated with this rule

condition

Type
craft\elements\conditions\ElementConditionInterface
Default value
null

View source

fieldUid

Type
string
Default value
null

The UUID of the custom field associated with this rule

View source

Public Methods

MethodDescription
getCondition()
getConfig()Returns the rule’s portable config.
getExclusiveQueryParams()
getGroupLabel()Returns the optgroup label the condition rule should be grouped under.
getLabel()Returns the rule’s option label.
getLabelHint()Returns the rule’s option label hint.
matchElement()
modifyQuery()
setFieldUid()Sets the UUID of the custom field associated with this rule.
setLayoutElementUid()Sets the UUID of the custom field layout element associated with this rule.

getCondition()

View source

Returns

craft\elements\conditions\ElementConditionInterface

getConfig()

Returns the rule’s portable config.

View source

Returns

array

Throws

getExclusiveQueryParams()

View source

getGroupLabel()

Returns the optgroup label the condition rule should be grouped under.

View source

Returns

string, null

getLabel()

Returns the rule’s option label.

View source

Returns

string

getLabelHint()

Since
4.6.0

Returns the rule’s option label hint.

View source

Returns

string, null

matchElement()

View source

Arguments

  • $element

modifyQuery()

View source

Arguments

  • $query

setFieldUid()

Sets the UUID of the custom field associated with this rule.

View source

Arguments

setLayoutElementUid()

Since
5.0.0

Sets the UUID of the custom field layout element associated with this rule.

View source

Arguments

Protected Methods

MethodDescription
defineRules()Returns the validation rules for attributes.
elementQueryParam()
field()Returns the first custom field instance associated with this rule.
fieldInstances()Returns the custom field instances associated with this rule, if known.
matchFieldValue()

defineRules()

Since
3.4.0

Returns the validation rules for attributes.

See \craft\fields\conditions\rules() for details about what should be returned.

Models should override this method instead of \craft\fields\conditions\rules() so \craft\fields\conditions\EVENT_DEFINE_RULES handlers can modify the class-defined rules.

View source

Returns

array

elementQueryParam()

View source

Returns

mixed

field()

Returns the first custom field instance associated with this rule.

View source

Returns

craft\base\FieldInterface

Throws

fieldInstances()

Since
5.0.0

Returns the custom field instances associated with this rule, if known.

View source

Returns

craft\base\FieldInterface[]

Throws

matchFieldValue()

View source

Arguments

  • $value

Returns

mixed