Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GridField breadcrumbs may use incorrect casting for titles #11174

Open
2 tasks done
kinglozzer opened this issue Mar 8, 2024 · 0 comments
Open
2 tasks done

GridField breadcrumbs may use incorrect casting for titles #11174

kinglozzer opened this issue Mar 8, 2024 · 0 comments

Comments

@kinglozzer
Copy link
Member

kinglozzer commented Mar 8, 2024

Module version(s) affected

5.0.0+

Description

Tentatively filing this as a bug... it could be argued it’s a feature request too, I think it’s somewhere in between.

I’m working on a module that’ll allow very basic “rich text editing” for titles (i.e. Markdown-based instead of TinyMCE). Part of that is using a custom DBField type for storing the title and controlling how it’s rendered. I can control how it’s rendered everywhere inside and outside of the CMS, except the GridField breadcrumb:

Screenshot 2024-03-08 at 12 51 04

This is because it accesses the property directly, which means it falls back to using the default casting (which is DBText):

$title = ($this->record->Title) ? $this->record->Title : "#{$this->record->ID}";

I’d like to propose changing this to $this->record->obj('Title') instead, so that if the database type for Title is changed to something other than DBVarchar, it uses the correct casting instead of always using DBText::forTemplate().

How to reproduce

Override title field type for an item that can be edited in a GridField (e.g. I’m using non-inline-editable elements):

DNADesign\Elemental\Models\BaseElement:
  db:
    Title: MyCustomDBField
class MyCustomDBField extends DBVarchar
{
    public function forTemplate()
    {
        return 'TEST';
    }
}

'TEST' should appear in the GridField breadcrumb, but doesn't.

Possible Solution

No response

Additional Context

No response

Validations

  • Check that there isn't already an issue that reports the same bug
  • Double check that your reproduction steps work in a fresh installation of silverstripe/installer (with any code examples you've provided)

PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant