View more context

 

jakx

Also, if I knew what module you're installing, I feel like there could be an opportunity for a terrible "sounds like you're stuck between a block and a ..." pun

Nik

Would someone be able to explain how SilverStripe distinguishes between a field and a method when specifying things like summary fields? It works fine, I'm just curious about the under-the-hood implementation. I've had a look through the code, but seems like I'm missing some parts there.

thats4shaw

I haven’t been following what you are trying to achieve but that error is telling you that it can’t find the class that you are trying to extend from. You’ll need to add:

  1. use SilverStripe\CMS\Model\VirtualPage;

gs

@jakx I'm trying to install silverstripe-mimevalidator,

gs

It's throwing a conflict on both dnadesign/silverstripe-elemental and silverstripe/userforms

theruss

@Nik Have a look at ViewableData::__get() 🙂

Nik

Looks good, although I don't get how summary_fields resolves a method without a getMethod? An entry named SomeMethod will work, even without having a getSomeMethod function, but just a SomeMethod function. How? Follow up would be how dot notation is being parsed, although for that I found GridFieldDataColumns.getValueFromRelation - not sure if it's the correct one

Nik

Thanks for your help with this 🙂

theruss

AFAIK $summary_fields will resolve methods without a "get" prefix, only if they're declared either as first-class, class-properties or through having been declared as a "Field" (which silverstripe defines as being a field in $db or in $has_one)

theruss

You can test this by declaring a randomly method Wibble() that returns the string "Pencils up nose" (Blackadder episode...) and calling it from $summary_fields.

theruss

If that works, and your GridField displays a column each of who's cells shows "Pencils up nose", then I couldn't tell you what sorcery was doing that...

Nik

So I have a method called Preview that is mapped to in summary_fields - it's literally just a method, and it returns a DBText. And that works - which I couldn't figure out

jakx

I got no puns for that sadly @gs 😅, best I got it "sounds like you're stuck between a block and an application/hard place". Sorry to let you down.

Also, adding new modules can take a bit of juggling, but you'll find a sweet spot after a bit of review. Good luck!

gs

thanks @jakx yeah I'm juggling between silverstripe-elemental and silverstripe/userforms which each says the other is not supported. Trying to update both modules together

jakx

My current project has both, including the dnadesign/silverstripe-elemental-userforms module. If that's any re-assurance @gs

gs

cool thanks @jakx just updated both modules and testing it out

🙌 (1)