Skip to content

Using Code for Row and Selector for Column, or vice versa, throws up an error message about not having anything to define rows or columns #28

@ShadowKyogre

Description

@ShadowKyogre

Expected Behavior

Fieldtype Matrix outputs rows defined by code and columns defined by a selector.

Actual Behavior

Fieldtype Matrix outputs an error saying one needs to use a Page Field or selectors. Screenshots can be attached of my own config to show how I reproduced this.

Steps to reproduce

  1. Set up a Matrix field with Code for row and Selector for column. Or the other way around. Just make sure it's not both Code nor both Selector.
  2. Use the field in a template.
  3. Try editing a page with that template.

Note:: It's easiest to reproduce this error when testing a $pages->find() query in the PHP code and comparing it to the selector output for the same row or column definition. $pages->find() is more useful in cases where rows or columns is defined by a Page Reference field on the page.

Where in the code does this need fixing?

https://github.com/kongondo/FieldtypeMatrix/blob/master/InputfieldMatrix.module#L301

if((!$parentRowColumnPageField) && (!$rowFindPagesCode || !$columnFindPagesCode) && (!$rowSelector || !$columnSelector))

In the above example case, the conditional evaluates to (true) && (false || true) && (false || true) == true.

Suggested Fix

if((!$parentRowColumnPageField) && (!$rowFindPagesCode && !$rowSelector) && (!$columnFindPagesCode && !$columnSelector))

In the above example case, the conditional evaluates to (true) && (false && true) && (false && true) == false. Which is what should be expected when using an asymmetric setup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions