bencarr / statamic-hyperlink

Hyperlink is a Statamic addon that expands the default Link fieldtype and allows you to store link text and target options alongside the link destination.
https://statamic.com/addons/bencarr/hyperlink
3 stars 1 forks source link

Feature Request: Allow multiple links in one Hyperlink field #11

Closed aaronbushnell closed 4 months ago

aaronbushnell commented 8 months ago

Every now and then a client wants to change a single Hyperlink field to a set of multiple. While it's possible to put a Hyperlink field into a Replicator it means you have to migrate all the old links into this new fieldtype. Instead, it would be great to have this capability baked-in so it can be easily enabled or disabled without requiring that migration.

bencarr commented 6 months ago

Just tagged v2.0.0-beta.1 which adds multiple links in a single field!

I’d love any feedback on the UI or the field configuration if you have a chance to check it out. I tried to keep it flexible for all the different ways I’ve run into this before, while keeping the defaults exactly like V1 to avoid any data migration.

There’s a small Upgrade Guide in the README, but the gist is there’s 2 new config options for min_items and max_items, which default to 0 and 1. Bumping up max_items adds a new “Add Link” button at the bottom of the field, and once there’s more than one link in a field you get some extra controls to reorder or delete the individual links.

For your original scenario, in V2 if you update the configuration on an existing field to support multiple links, you won’t need a data migration (the data will just be updated next time the entry is saved), you’ll just need to update your templates to expect an array of links.

aaronbushnell commented 5 months ago

This is excellent, @bencarr! Really makes the experience super nice to not have to migrate if the client wants additional links. Great work!

bencarr commented 4 months ago

🎉 2.0 is out now with multiple links in a single field!

aaronbushnell commented 4 months ago

Awesome work, @bencarr! Congrats! 🥳