Should $summary_fields be able to pass arguments to methods? #2896

kinglozzer opened this Issue Feb 24, 2014 · 4 comments

4 participants

SilverStripe Ltd. member

For example:

private static $summary_fields = array(
    'Author' => 'Author',
    'Content.LimitCharacters(50)' => 'Content'

My preference is to move away from this kind of eval-ish syntax towards using anonymous functions, any thoughts on that?

SilverStripe Ltd. member

I agree that it would be a cleaner solution, there’s probably more margin for error using this syntax than anonymous functions as well. However, we can’t use class properties to configure it which makes the implementation much less simple for developers.

Any ideas on how/where you’d define your anonymous functions? You could override summaryFields(), but you can already do that anyway.


My preference would be for people to override summaryFields for complex situations like this.

@simonwelsh simonwelsh added the 3.1 label Mar 15, 2014
@kinglozzer kinglozzer closed this May 23, 2014

Just make a method that returns the summary in the format you expect.

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