12

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

4
  • Have you got an example. I could not find one in Mage 1.8 or 1.9 Jun 25, 2014 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. Jun 25, 2014 at 16:08
  • Ah I get you. Though do any modules actually use it or it hidden away? Jun 25, 2014 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 Jun 25, 2014 at 18:19

1 Answer 1

16

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.

3
  • 6
    Beautiful bit of Magento archeology - love it! Jun 25, 2014 at 17:18
  • 1
    Impressed with this, I am.
    – philwinkle
    Jun 25, 2014 at 17:20
  • Note that you can override the Magento admin theme to show hints by default. I've also modified it to change textbox font to Consolas for better legibility, etc.
    – thdoan
    Apr 5, 2016 at 3:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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