How To Set Hint Text To Invisible When Leaving Its Related Input Focus?

Hi everyone, I’m quite a newbie to Yii and I’m playing around with the “hint” property of CActiveForm. However, while the hint is correctly hidden until I focus the input and shown on that event, it remains even when I focus another input. I’d like the first hint to disappear when I select a different input. What would be a convenient option to achieve that?

My code:


<?php echo $form->textFieldRow($model, 'myInputName', array('class' => 'span5', hint'=>'My hint for this input')) ?>



Thanks in advance to anyone who will help :)

Hi you can use placeholder

like


<?php echo $form->textFieldRow($model, 'myInputName', array('class' => 'span5', 'placeholder'=>'My hint for this input')) ?>



or i think you miss the hint quote like ‘hint’

yes I mistyped when replacing the hint name :)

I tried the placeholder attribute before, but it’s not exactly what I needed since my “hint” text is actually the detailed description about what the input represents, i.e.

and when I click on it it should become something like

and go back to the first view when I select another.

I’m also considering adding a question mark icon with some kind of tooltip on the right of the input as an alternative solution but I’m not quite sure on how to do that (I’m using the Yiibooster extension, if that can help).

EDIT: The most neat way I found would be the one described here -> http://michd.me/blog/form-input-help-on-focus/ but I can’t use it since the adjacent sibling of the input is always the hidden"help-block error" autogenerated by textrowfield. :(

Hi,

please see it

i hope it’s some help.

I did try it, but it’s not suiting my needs since the text I want to show could be quite lenghty as it is meant to be a description and not an example. I ended up using the Yii wrapper for Tooltipster and attaching it to a glyphicon which suits my intended design a bit more. This is a screenshot if anyone wonders.