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.
Public Properties ​
Property | Description |
---|---|
condition | craft\elements\conditions\ElementConditionInterface |
fieldUid | string – The UUID of the custom field associated with this rule |
condition
​
- Type
- craft\elements\conditions\ElementConditionInterface
- Default value
null
fieldUid
​
- Type
- string
- Default value
null
The UUID of the custom field associated with this rule
Public Methods ​
Method | Description |
---|---|
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()
​
Returns ​
craft\elements\conditions\ElementConditionInterface –
getConfig()
​
Returns the rule’s portable config.
Returns ​
Throws ​
- yii\base\InvalidConfigException
if the rule is misconfigured
getExclusiveQueryParams()
​
getGroupLabel()
​
Returns the optgroup label the condition rule should be grouped under.
Returns ​
getLabel()
​
Returns the rule’s option label.
Returns ​
getLabelHint()
​
- Since
- 4.6.0
Returns the rule’s option label hint.
Returns ​
matchElement()
​
Arguments ​
$element
modifyQuery()
​
Arguments ​
$query
setFieldUid()
​
Sets the UUID of the custom field associated with this rule.
Arguments ​
$uid
(string)
setLayoutElementUid()
​
- Since
- 5.0.0
Sets the UUID of the custom field layout element associated with this rule.
Arguments ​
Protected Methods ​
Method | Description |
---|---|
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.
Returns ​
elementQueryParam()
​
Returns ​
mixed
field()
​
Returns the first custom field instance associated with this rule.
Returns ​
Throws ​
- yii\base\InvalidConfigException
if fieldUid or\craft\fields\conditions\layoutElementUid
are invalid
fieldInstances()
​
- Since
- 5.0.0
Returns the custom field instances associated with this rule, if known.
Returns ​
Throws ​
- yii\base\InvalidConfigException
if fieldUid or\craft\fields\conditions\layoutElementUid
are invalid
matchFieldValue()
​
Arguments ​
$value
Returns ​
mixed