Zauberfisch / silverstripe-easy-linkfield

SilverStripe inline link field that allows adding one or multiple links to any object and saves into a single DB field
BSD 3-Clause "New" or "Revised" License
2 stars 0 forks source link

php7.2 compatibility & template error #1

Closed silverstripesk closed 3 years ago

silverstripesk commented 3 years ago

Hi Zauberfisch,

looks like excellent module, but isn't working for me (php 7.2, ss 4.7):

1) dev/build is throwing error after installation: Parse error: syntax error, unexpected ')' in /.../vendor/zauberfisch/silverstripe-easy-linkfield/src/Link/PhoneLink.php on line 31

I fixed it by simply removing unneeded commas.

After this fix is backend working nicely.

2) But frontend throws another error:

[Emergency] Uncaught Exception: Could not find field 'Link'. GET /tim/detail/emil-horvath?flush Line 138 in /.../vendor/zauberfisch/silverstripe-serialized-dataobject/src/AbstractDataObject.php

I am using this template: `<% loop $Links.getValue %>

<!-- And depending on the type: $Page (internal), $PageID (internal), $URL (external), $File (file), $FileID (file), $Email (email), $CountryPrefix (phone), $Number (phone), $PhoneNumber (phone) -->
<a href="$Link" <% if $NewTab %>target="_blank"<% end_if %>>$Title</a>
<% end_loop %>`

This is model: use zauberfisch\LinkField\LinkListField; use zauberfisch\LinkField\DBLinkList; class MaxTeamMember extends DataObject { private static $singular_name = 'Team member'; private static $plural_name = 'Team members'; private static $db = [ 'Links' => DBLinkList::class ]; public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldToTab('Root.Main', LinkListField::create('Links', 'Užitočné odkazy')->setOrderable(true)); return $fields; } }

This is stored in DB: {"items":[{"fieldsData":{"Title":"example.com","URL":"https:\/\/example.com"},"listsData":[],"#type":"zauberfisch\\LinkField\\Link\\ExternalLink"}],"#type":"zauberfisch\\SerializedDataObject\\ArrayList"}

Regards

Pali

Zauberfisch commented 3 years ago

Thank you for the report. You're right, those trailing commas are not necessary and not supported in php 7.1/7.2. I've fixed it in 94045ca2a7d9bad71898a37690f92b57bd712266 and released it as v1.0.1. After you update, it should now work.

Zauberfisch commented 3 years ago

@silverstripesk oh, sorry, I've only skimmed your post and thought the 2nd part was just error messages. I've completely missed half of your message.

I've now pushed a second update that also fixes the template issue in e60fba14cc0fb9cdd5d28020736905e453523a55 and released it as v1.0.2. Could you please update and let me know if it's working now?

Zauberfisch commented 3 years ago

@silverstripesk You also have to update your template code, please see the updated README.md