1
votes

I am trying to learn how to use Drupal, and until i've been doing fine on my own. however there is one module that's teasing me - the Field Placeholder module.

basically what it does, it adds a placeholder entry to a field widget. per standard these widgets are text, number and mail modules. My problem is i can't figure out how i should extend the number of activated widgets, more specifically i want to add a placeholder attribute to the link module (https://drupal.org/project/link)

It says i can add other widgets via the hook_field_placeholder_info(), but how does that work? The documentation for this module is very limited, so please help a noob :)

1

1 Answers

1
votes

Modules that provide an API, in this case defines hook_field_placeholder_info, usually have these functions defined in their .api.php file. For the field_placeholder module, that would be the field_placeholder.api.php file.

In there, you'll find:

/**
 * Define field placeholder supported widgets.
 *
 * @return
 *   An array whose keys are the widget names and whose value are the widget
 *   item where the placeholder will be attached.
 */
function hook_field_placeholder_info() {
  return array(
    'text_textfield' => 'value',
    'number' => 'value',
    'email_textfield' => 'email',
  );
}

From this, it looks like you need to implement this hook in your fork of the link module that returns an array something along the lines of:

function link_placeholder_info() {
  return array(
    'link_field' => 'value',
  );
}

Granted, I haven't looked in the link module to see what the actual values are, but that should get you going. It might be a good idea to take a look at the text, number, and email modules to see how those values in the example line up with the actual values in their respective modules too.