Skip to content

Commit

Permalink
Add nullpage check
Browse files Browse the repository at this point in the history
  • Loading branch information
solonmedia committed Jan 23, 2024
1 parent c99a189 commit 3ed5e4f
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions FieldtypeGrapick.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,27 @@ public function __construct() {
*
* @param Page $page
* @param Field $field
* @return InputfieldCssGradient
* @return CssGradient
*
*/
public function getInputfield(Page $page, Field $field) {
/** @var InputfieldCssGradient $inputfield */
/** @var InputfieldGrapick $inputfield */

$inputfield = $this->wire('modules')->get('InputfieldGrapick');

if($page->template->pageClass == 'RepeaterMatrixPage') {
if($page->getField($field->name)) {
$field_in_context = $page->fieldgroup->getFieldContext($field, "matrix$page->repeater_matrix_type");
if($field_in_context) {
$field = $field_in_context;
$context = ($page && $page->id) ? $field->getContext($page->template) : $field;

if(!($page instanceof NullPage)) {
if($page->template->pageClass == 'RepeaterMatrixPage') {
if($page->getField($field->name)) {
$field_in_context = $page->fieldgroup->getFieldContext($field, "matrix$page->repeater_matrix_type");
if($field_in_context) {
$field = $field_in_context;
}
}
$inputfield->setField($field);
$inputfield->setPage($page);
}
$inputfield->setField($field);
$inputfield->setPage($page);
}

return $inputfield;
Expand Down Expand Up @@ -105,11 +109,19 @@ public function getBlankValue(Page $page, Field $field) {

$context = ($page && $page->id) ? $field->getContext($page->template) : $field;

if($page->template->pageClass == 'RepeaterMatrixPage') {
if($page->getField($field->name)) {
$context = $page->fieldgroup->getFieldContext($field, "matrix$page->repeater_matrix_type");
if(!($page instanceof NullPage)) {
if($page->template->pageClass == 'RepeaterMatrixPage') {
if($page->getField($field->name)) {
$field_in_context = $page->fieldgroup->getFieldContext($field, "matrix$page->repeater_matrix_type");
if($field_in_context) {
$field = $field_in_context;
}
}
$inputfield->setField($field);
$inputfield->setPage($page);
}
}
}

$gradient = new CssGradient(); //Context for this object isn't important because there is no config.

return $gradient;
Expand Down

0 comments on commit 3ed5e4f

Please sign in to comment.