I really like the idea of this module.
Is it possible to use this module with webform?

Comments

quicksketch’s picture

You can use this module with Webform by theming any Webform (as is documented in the THEMING.txt file that comes with Webform). Then add the #hint property to any textfield (as is documented in the README.txt file that comes with Hint). I don't anticipate building direct support for Hint into Webform however, since generally it is not suitable for long forms that are of the Webform nature.

gthing’s picture

I've read over your comment and through both the readme.txt from Hint and the theming.txt file from Webform. I'm lost.

Is there a tutorial for doing this somewhere? I can't even get webform-form.tpl.php to work, let alone breaking out the different elements of the form, let alone figuring out how to "set $element[#hint']."

I know webform can be used for long forms, but people seem to use it for short forms (like quick contact in the sidebar or something). It's already provided by a block (which seems to accomodate short forms), it would really be nice if there was a checkbox on each field for "clear on click." Trying to integrate Hint into webform seems to require super leet programming skills.

gthing’s picture

I was able to achieve what I wanted using the Compact Forms module. Very easy to use and works like a champ: http://drupal.org/project/compact_forms

nvisioncurtis’s picture

Hi There,

I was reading this post and I think you were refering to something I am tryijnjg to do... getting the compact form module to work with webforms...

It does not seem to work for me however, is there a trick?

quicksketch’s picture

Title: with webform. » Combining Hint with Webform
tomseeber’s picture

Category: support » bug

Hi All, Hi Quicksketch,

I did try out the instructions as listed here, if I did something wrong, I would love to understand where I misunderstanding.

First, as per web form documents, I was able to create a custom template for a webform node.
For me this was be webform-form-5.tpl.php and was able to make changes to that appeared in the form.
The Hint module was enabled and working in other places.

In this web form I have a webform field called "Testing It"
Using my understand of the method described in the Hint Readme File, I added the following code

dpm($form['submitted']['testing_it']['#title']);
unset($form['submitted']['testing_it']['#title']);
$form['submitted']['testing_it']['#hint'] = t('Testing It');
dpm($form['submitted']['testing_it']);

Which seemed roughly equivalent to the hook_form_alter method ( although again please let me know if this assumption is not correct).

I added the dpm's so I can just see exactly what was in the title for a webform entry.
I tried this also with the hint_set_hint($form['submitted']['testing_it'], t('Testing_it'));
(This is listed in the documentation as texthint_set_hint, but that throws an error). The hint_set_hint adds a #hint to the form just fine however.

This was followed by the normal Webform drupal_render[$form]
In both cases the #hint was part of the listing for the form field as I expected.
Upon flushing the cache, this does not seem to do anything.

Should I render each part the form separately although I can not see how that would make a difference ( and how would I do that).

If I thinking wrong on this, please by all means let me know what I am misunderstanding by your instructions, Quicksketch. I'll gladly write up a longer How-To documenting exactly how to do this, if I get this working.

Cristobal Wetzig’s picture

Hope this helps someone, this changes all webform texfield inputs to use Hint (Uses the title)

/**
* implements form alter
*/
function YOURMODULE_form_alter(&$form, &$form_state, $form_id){
  if (strstr($form_id,'webform_client')!==FALSE){
    _YOURMODULE_set_title_as_hint($form);
  } 
}
/**
* Dirty helpfunction.
*
**/
function _YOURMODULE_set_title_as_hint(&$form){
  $types_to_change=array('textfield');
  foreach ($form['submitted'] as &$form_value){
    if (in_array($form_value['#type'], $types_to_change)){
      $form_value['#hint']=$form_value['#title'];
      unset($form_value['#title']);
    }
  }  
}


RMani’s picture

did not work :(

Anonymous’s picture

Have you tried unsetting the default values?

  ...
  $form_value['#hint']=$form_value['#title'];
  unset($form_value['#title']);
  unset($form_value['#default_value']);
}
...
hhopkins’s picture

I had to make a slight modification to #7 in order make it work for me. The hint_pre_render function needed to be added to each field in order to execute the hint process. Here is my code.

/**
* Dirty helpfunction.
*
**/
function _YOURMODULE_set_title_as_hint(&$form){
  $types_to_change = array('textfield');
  foreach ($form['submitted'] as &$form_value){
    if (in_array($form_value['#type'], $types_to_change)){
      $form_value['#hint'] = $form_value['#title'];
      $form_value['#pre_render'][] = 'hint_pre_render';
      unset($form_value['#title']);
    }
  } 
}
hmartens’s picture

In which file would I add this to?

Thanks for the help!