2

The contributed project Field placeholder lets one use HTML5 placeholder attribute. The project page says:

By default, this module integrates text, number and mail modules, but any other widget type can be added through hook_field_placeholder_info().

I've tested this with a “Text” field, and it works as advertised.

I want to add hook_field_placeholder_info() for the Link module.

According to field_placeholder.api.php, this hook should return:

An array whose keys are the widget names and whose value are the widget item where the placeholder will be attached.

So far I've tried this:

/**
 * Implements hook_field_placeholder_info().
 */
function mymodule_field_placeholder_info() {
  return array(
    'link_field' => 'value',
  );
}

This puts the widget for the placeholder settings on the admin page where one manage the link file, but setting a placeholder value has no effect when I create a new node with a link field.

I believe the problem is “value”. According to the documentation, it should be the “widget item where the placeholder will be attached”.

I am not sure what that is. So far I've tried “value”, “link_field”, “link”, and “url” (clearing the cache before testing each in turn), but none of these work for the link field.

So: How to write hook_field_placeholder_info() for the link module?

1 Answer 1

1

There is a feature request to add support for the link module. Unfortunate that patch has not been committed yet, but you can use/apply the patch in #5 and use

/**
 * Implements hook_field_placeholder_info().
 */
function mymodule_field_placeholder_info() {
  return array(
    'link_field' => 'url',
  );
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.