Add prefix and suffix to textfield component

BrianJubal - June 4, 2008 - 21:27
Project:Webform
Version:5.x-2.0
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

I've been searching for a few days now but can't find something like what I'm looking for. My boss would like me to add a suffix like lbs. or machines to the webform that is inline and right after the textfield of one of the webform components, so that it would look something like:

Weight:
|_TEXTFIELD_| lbs.
This is the weight of the object.

I am assuming the easiest way to do this would be to use hook_form_alter and add a #field_prefix to the form, but if there is a better way, please let me know! Otherwise, please help me find how to access and alter the individual components.

#1

quicksketch - June 4, 2008 - 23:08

A form_alter or theming is the easiest approach currently. I'm open to accepting a patch for adding #field_prefix and #field_suffix options to the textfield component also, which would make this much easier for other users.

#2

BrianJubal - June 10, 2008 - 17:06

So you know, a patch that does this very thing is in my pile of things to do. I hope I can have one pretty soon. I've never built a true patch, so I'll need a little grace for my first attempt. :)

#3

BrianJubal - June 26, 2008 - 22:23

Again, first attempt at creating a patch. Let me know what I can do better or if I overlooked something.

AttachmentSize
webform_textfield_presuffix.patch1.59 KB

#4

BrianJubal - June 26, 2008 - 22:27
Version:5.x-2.0-beta3» 5.x-2.0

I grabbed 5.x-2.0 (the latest) before I created this patch.

#5

BrianJubal - June 27, 2008 - 13:30
Status:active» patch (code needs review)

#6

quicksketch - June 29, 2008 - 23:57
Status:patch (code needs review)» fixed

Thanks! I committed this with the addition of including the prefix in sent e-mails. We could probably include it also in analysis and table views, but we can save that for a later time.

Here's the commit: http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/webform/com...

#7

quicksketch - June 30, 2008 - 00:34
Title:hook_form_alter components - adding prefix or suffix» Add prefix and suffix to textfield component
Component:Documentation» Code
Category:support request» feature request

Updating title for posterity.

#8

Anonymous (not verified) - July 14, 2008 - 01:46
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.