I'd love to see a way to add Linkit support to any eligible element, as defined in hook_linkit_allowed_field_elements().

Out of the box, this includes textfield, textarea, textarea_with_summary, and link_field. These element types already have an #after_build callback attached. However, linkit_field_element_after_build() only currently supports Field API elements.

The good news is that this is pretty easy to implement. All we need to do is refactor linkit_field_element_after_build() a bit. I'm putting together a patch.

Comments

joelstein created an issue. See original summary.

joelstein’s picture

Status: Active » Needs review
StatusFileSize
new3.62 KB

Here's a patch which adds Linkit support for any eligible element a #linkit array is attached. For example, you can now do something like this:

$form['path'] = array(
  '#type' => 'textfield',
  '#linkit' => array(
    'profile' => 'my_profile',
  ),
);

You can specify the 'profile', whether or not it's 'enabled', the 'button_text', and override the 'js_setttings' array.

No other changes were needed. I tested that normal Field API support still works for the default field types shipped with Linkit.

joelstein’s picture

StatusFileSize
new3.64 KB

Oops, I left one hard-coded testing thing in there. Here's a patch that should work. :)

joelstein’s picture

Any chance we can commit this? It's been helpful for custom modules we write to add the awesome Linkit functionality to places where it's currently missing but very helpful, such as in Ctools modals with Fieldable Panels Panes and Panels IPE, and also in coordination with #2514928: Support for default drupal menu system for menu link support.

  • anon committed c617212 on 7.x-3.x authored by joelstein
    Issue #2651404 by joelstein: Allow Linkit support for any eligible...
anon’s picture

Status: Needs review » Fixed

Thanks for patch.

joelstein’s picture

Thanks a bunch, I appreciate it.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

joseph.olstad’s picture

was this ever ported to the Drupal 8 version of linkit?