Skip to content

When FieldtypeOptions field is included into the joinFields option, the returned value has always the first option only. #1616

@dadish

Description

@dadish

Short description of the issue

When FieldtypeOptions field is included into the joinFields option, the returned value of the FieldtypeOptions field has the first option only. Even if the actual assigned values are multiple.

Steps to reproduce the issue

Steps to reproduce the issue:

  1. Create a FieldtypeOptions field with multivalue support. Let's call it a days field and set the days of the week as options.
  2. Add the field to a template.
  3. Edit a page with that field and select more than one value.
  4. In the template file find the target page with joinFields option with days field. Like below
<?php

$basicPages = $pages->find("id=1015", [
  'joinFields' => [ 'days' ]
]);

foreach ($basicPages as $basicPage) {
  echo "<h4>{$basicPage->title}: {$basicPage->id}</h4>";
	
  foreach ( $basicPage->days as $day) {
    echo $day->title;
    echo "<br />";
  }
}

Expected behavior

Expected to see multiple days listed that were assigned to the page in days field.

Actual behavior

Seeing only the first, single day.

Optional: Suggestion for a possible fix

I think we can fix it by handling a concatenated string of multiple option values in wakeupValue method of the FieldtypeOptions module.

Here is a possible fix #241.

Setup/Environment

  • ProcessWire version: 3.0.203
  • (Optional) PHP version: 7.4.30
  • (Optional) MySQL version: mariadb:10.8.3
  • (Optional) Any 3rd party modules that are installed and could be related to the issue: N/A

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions