Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add conditional field layouts support to Preparse field type #94

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/fields/PreparseFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
use craft\db\mysql\Schema;
use craft\elements\db\ElementQuery;
use craft\elements\db\ElementQueryInterface;
use craft\fields\conditions\DateFieldConditionRule;
use craft\fields\conditions\NumberFieldConditionRule;
use craft\fields\conditions\TextFieldConditionRule;
use craft\gql\types\DateTime as DateTimeType;
use craft\helpers\DateTimeHelper;
use craft\helpers\Db;
Expand Down Expand Up @@ -244,4 +247,24 @@ public function getContentGqlType(): Type|array
}
return parent::getContentGqlType();
}

/**
* @inheritdoc
*/
public function getElementConditionRuleType(): array|string|null
{
switch ($this->columnType) {
case Schema::TYPE_DATETIME:
return DateFieldConditionRule::class;
case Schema::TYPE_DECIMAL;
case Schema::TYPE_FLOAT:
case Schema::TYPE_INTEGER:
return NumberFieldConditionRule::class;
case Schema::TYPE_MEDIUMTEXT:
case Schema::TYPE_TEXT:
return TextFieldConditionRule::class;
default:
return TextFieldConditionRule::class;
}
}
}