Take the 2-minute tour ×
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

I've found opaque reference to a <hint/> tag in system.xml files. What's the deal with this tag? Is it's use documented anywhere?

share|improve this question
    
Have you got an example. I could not find one in Mage 1.8 or 1.9 –  David Manners Jun 25 at 15:19
    
@DavidManners See below — this was a more a "I want to document Magento" question in response to a question someone tweeted me than a "I have a problem" question. Other people's knowledge and context is more than welcome though. –  Alan Storm Jun 25 at 16:08
    
Ah I get you. Though do any modules actually use it or it hidden away? –  David Manners Jun 25 at 18:09
    
@DavidManners It's hidden away, and the way the system configuration HTML is setup it doesn't even work. I think the hint feature of the field rendering might work on other forms (product editing, etc), but that's not driven by system.xml. Also relevant, Marius's module creator has its own help/hint feature. alanstorm.com/magento_ultimate_module_creator_review –  Alan Storm Jun 25 at 18:19

1 Answer 1

up vote 8 down vote accepted

I'm not sure about EE, but in CE this is a vestigial tag from a never completed help system. The intent appears to have been to give each form field in the System configuration section a small "hint", or help text.

The help text is added when the field element is created

#File: app/code/core/Mage/Adminhtml/Block/System/Config/Form.php
$hint  = (string)$element->hint ? Mage::helper($helperName)->__((string)$element->hint) : '';

//...

$field = $fieldset->addField($id, $fieldType, array(
    'name'                  => $name,
    'label'                 => $label,
    'comment'               => $comment,
    'tooltip'               => $tooltip,
    'hint'                  => $hint,
    'value'                 => $data,
    'inherit'               => $inherit,
    'class'                 => $element->frontend_class . $sharedClass . $requiresClass,
    'field_config'          => $element,
    'scope'                 => $this->getScope(),
    'scope_id'              => $this->getScopeId(),
    'scope_label'           => $this->getScopeLabel($element),
    'can_use_default_value' => $this->canUseDefaultValue((int)$element->show_in_default),
    'can_use_website_value' => $this->canUseWebsiteValue((int)$element->show_in_website),
));

That first line reads the value of a <hint/> in system.xml.

Next, when Magento renders the field as HTML, the last thing it does is add the hint in a nested div.

#File: app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field.php
$html.= '<td class="">';
if ($element->getHint()) {
    $html.= '<div class="hint" >';
    $html.= '<div style="display: none;">' . $element->getHint() . '</div>';
    $html.= '</div>';
}
$html.= '</td>';

Finally, there's a small bit of javascript that's called on an admin page load.

#File: app/design/adminhtml/default/default/template/system/config/js.phtml
function showHint() {    
    $$('.hint').each(function(element){
        Event.observe(element, 'mouseover', function(){            
            element.down().show()
        });
        Event.observe(element, 'mouseout', function(){
            element.down().hide()
        });
    });
}

This javascript sets up event handlers such that mousing in or out of the help text will make it appear. The intent being this "hint" would help users understand what each field does.

The problem? The HTML/CSS on the backend makes the hint td a single pixel wide. This prevents anyone mousing over the hint to view it. Try adding a hint to your field configuration and then running the following from your browser's javascript console

$$('.hint').each(function(el){
    el.down().show();
});

You'll see something like this.

enter image description here

(the This is a hint text).

I've always chalked this up as one of those "Best Laid Plans" thing that got dropped once Magento launched.

share|improve this answer
3  
Beautiful bit of Magento archeology - love it! –  kalenjordan Jun 25 at 17:18
    
Impressed with this, I am. –  philwinkle Jun 25 at 17:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.