I selected an option to use descriptions instead, so I could have labels showing too. The Name field module that is supported by Webform does not have Description field, but it uses Label field (not the main one) for every field it provides (e.g. First Name, Last Name) and their CSS class is 'description'.
a

What I'm trying to achieve is:
b

CommentFileSizeAuthor
2.jpg14.31 KBmatas.k
1.jpg169.86 KBmatas.k

Comments

guschilds’s picture

vibrasphere,

Webform Hints only works with components that come with the Webform module unless custom code is added. This is because contributed modules that add Webform components often work in very different ways and it is impossible to account for all of them. For this reason, a couple of hooks have been added (see webform_hints.api.php for more info).

Of those hooks, hook_webform_hints_fieldtypes_alter() can't be used to add name_element components because their array structure is unlike core Webform components and the module will not handle them properly. Instead, we must use hook_webform_hints_element_alter(). I have achieved what you desire using the following code (in a custom module):

/**
 * Implements hook_webform_hints_element_alter().
 */
function mymodule_webform_hints_element_alter(&$element, &$required_label) {
  // Adds hints to Name components from the contributed Name module.
  if ($element['#type'] == 'name_element') {
    // Use each component's title as its hint. The title is then cleared so it
    // does not appear directly under the field containing the same hint.
    foreach (array_keys($element['#components']) as $name_component) {
      $title = $element['#components'][$name_component]['title'];
      $element['#components'][$name_component]['attributes']['placeholder'] = $title;
      $element['#components'][$name_component]['title'] = '';
    }
  }
}

This will use each field's label as its placeholder instead of printing the label under each field.

Please give it a shot and let us know how it goes. Thanks!

matas.k’s picture

Status: Active » Fixed

You should commit this to dev version.

guschilds’s picture

Status: Fixed » Closed (works as designed)

Thanks for letting us know that worked for you. For now we're keeping the module simple and only supporting Webform components. We may reconsider if enough interest is shown by the community.