Skip to content

Field support request: Nova Stack field #187

@marcobax

Description

@marcobax

When using a Nova Stack field and exporting a Nova resource to Excel the value inside the cell is empty

Example field:

  Stack::make(__('Stack field'), [
      Text::make(__('Some value'), 'some.value'),
      Text::make(__('Something else'), 'something.else'),
]),

In the file:

Maatwebsite\LaravelNovaExcel\Actions inside the method replaceFieldValuesWhenOnResource the values are resolved using $field->value. This will output NULL in case of a Stack field.

It would be nice to have all of the fields inside a Stack field to be automatically flattened. I've solved it (in my index fields) by adding this:

foreach ($fields as $index => $field)
  if ($field->component === 'stack-field' && $field->lines) {
      unset($fields[$index]);
  
      foreach ($field->lines as $item => $line) {
          $fields = array_merge(array_slice($fields, 0, $index + $item), [$line], array_slice($fields, $index + $item));
      }
  }
}

Kind regards,

Marco

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions