diff --git a/wire/core/Field.php b/wire/core/Field.php index 5a77debe..75c33680 100644 --- a/wire/core/Field.php +++ b/wire/core/Field.php @@ -711,6 +711,22 @@ class Field extends WireData implements Saveable, Exportable { return $fieldgroup->getFieldContext($this->id, $namespace); } + /** + * Does this field have context settings for given Page/Template? + * + * #pw-group-retrieval + * + * @param Page|Template|Fieldgroup|string $for Specify Page, Template, or template name string + * @param string $namespace Optional namespace (internal use) + * @return Field|bool + * @since 3.0.163 + * @see Field::getContext() + * + */ + public function hasContext($for, $namespace = '') { + return $this->getContext($for, $namespace, true); + } + /** * Set the roles that are allowed to view or edit this field on pages. * diff --git a/wire/modules/Fieldtype/FieldtypePage.module b/wire/modules/Fieldtype/FieldtypePage.module index 1d0536eb..fc168988 100644 --- a/wire/modules/Fieldtype/FieldtypePage.module +++ b/wire/modules/Fieldtype/FieldtypePage.module @@ -130,6 +130,8 @@ class FieldtypePage extends FieldtypeMulti implements Module, ConfigurableModule * */ public function ___wakeupValue(Page $page, Field $field, $value) { + + if($field->hasContext($page)) $field = $field->getContext($page); $template = null; $template_ids = self::getTemplateIDs($field); @@ -245,6 +247,8 @@ class FieldtypePage extends FieldtypeMulti implements Module, ConfigurableModule */ public function ___sleepValue(Page $page, Field $field, $value) { + if($field->hasContext($page)) $field = $field->getContext($page); + $sleepValue = array(); if($field->get('derefAsPage') > 0) { @@ -740,7 +744,7 @@ class FieldtypePage extends FieldtypeMulti implements Module, ConfigurableModule /** * Update a DatabaseQuerySelect object to match a Page * - * @param DatabaseQuerySelect $query + * @param DatabaseQuerySelect|PageFinderDatabaseQuerySelect $query * @param string $table * @param string $subfield * @param string $operator