Skip to main content
12 events
when toggle format what by license comment
Mar 15, 2016 at 9:31 history edited artfulrobot CC BY-SA 3.0
added 120 characters in body
Mar 15, 2016 at 9:29 vote accept artfulrobot
Mar 9, 2016 at 15:36 comment added user21641 Yeah sorry, I mean field widget in my first comment :D
Mar 9, 2016 at 13:53 answer added Berdir timeline score: 3
Mar 9, 2016 at 13:20 comment added artfulrobot I meant field_collection
Mar 9, 2016 at 13:03 comment added artfulrobot OK, thanks for clarifying. So I need to make a new field type, or use field_group to group a link and a text/select field for the classes.
Mar 9, 2016 at 13:01 comment added mradcliffe No, there is no field schema alter hook in either Drupal 7 or Drupal 8. Edit: Actually, I guess you could alter the plugin definition, provided your own class, implement schema method, and then all link fields will have that schema from then on. This seems like a lot of behavior to change for something like a custom menu system.
Mar 9, 2016 at 12:52 comment added artfulrobot So there's not a sort of "alter" option where I can alter an existing field (link) to add the extra part?
Mar 9, 2016 at 12:47 comment added mradcliffe I think the formatter is a good idea, but it probably doesn't fit @artfulrobot's use case of having users save arbitrary styling clues for link data. You can extend the link class and give it a different annotation and change the schema method (similar to Drupal 7). This creates a new field type plugin. File and Image field type plugins work similarly. This won't do anything about your current data though and you'll need to migrate.
Mar 9, 2016 at 12:45 comment added artfulrobot Thanks for the hint. The field formatter seems the third thing I'd need to create. First I need somewhere to store the classes data, then I need a widget enabling user to specify classes, then I need a formatter to apply them to the HTML.
Mar 9, 2016 at 11:54 comment added user21641 Just create new field formatter plugin and extend the \Drupal\link\Plugin\Field\FieldFormatter\LinkFormatter
Mar 9, 2016 at 11:51 history asked artfulrobot CC BY-SA 3.0