PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » HTML » HTML_QuickForm » Bug #1792

"helpInfo" to show next to a field to explain it's purpose

Details

Request #1792"helpInfo" to show next to a field to explain it's purpose
Submitted2004-07-05 11:39 UTC
Fromscott at evolove dot net
StatusNo Feedback
PackageHTML_QuickForm
PHP VersionIrrelevant
OSIrrelevant
Roadmaps(Not assigned)

Comments

[2004-07-05 11:39 UTC] scott at evolove dot net

Description:
------------
It's common for some fields to be confusing to a user (such as entering last 3 digits on the back of a CC), so I was required to implement "helpInfo" for my project - I think this should be part of the base QF package.

Modifications:
*element.php
*var $_helpInfo added, with getters/setters
*Renderer/Default.php
*function renderElement modified
*function _prepareTemplate modified (new signature)
*custom template updated of course, to add a third colum to table output in default renderer

Reproduce code:
---------------
var $_elementTemplate =
"\n\t<tr valign=\"middle\">\n\t\t<td align=\"left\" width=\"20%\" ><!-- BEGIN required --><span style=\"color: #ff0000\">*</span><!-- END required --><b>{label}</b></td>\n\t\t<td align=\"left\"><!-- BEGIN error --><span style=\"color: #ff0000\">{error}</span><br /><!-- END error -->\t{element}</td><td align=\"right\">{helpInfo}</td>\n\t</tr>";

var $_helpInfoTemplate =
"<span style=\"border: 1px dotted #ccc; padding: 5px; width: 100px; background-color: #c09; color: white;\">{helpInfo}</span>";

---

// sm 05/07/2004 10:46AM test helpInfo
$form->addElement('text', 'helpInfoTest', 'Help Info Test', array('size' => (FORM_FIELD_CC_SIZE + 3), 'maxlength' => (FORM_FIELD_CC_SIZE + 3)));
$elem =& $form->getElement('helpInfoTest');
$elem->setHelpInfo('this is some here help info, bro');

Expected result:
----------------
a purplish box, aligned to the far right with helper information inside to explain what that form field is all about

[2004-07-05 11:44 UTC] scott at evolove dot net

Note, that this solution works for groups as well (because HTML_QuickForm_group extends HTML_QuickForm_element).

If you want my code to poke at my code, it is available here:

http://www.badunka.com/files/QuickForm.zip

I will notify you via this bug report if I update it (going to review it later today)