Adding attribute tooltip to all CFormInputElement(s)

Hey guys,

what do think of adding one more attribute to CFormInputElement::htmlOptions() e.g.:

result example:




public static string activeTextField(CModel $model, string $attribute, array $htmlOptions=array ( ))



where




htmlOptions = array(

...

   'tooltip' => 'Enter only <strong>numeric</strong> characters.'

   'tooltipCss' => 'my_tooltip'  // optional, default "css_tooltip"

...

)



would produce:




<?php if(!empty($htmlOptions['tooltip'])): ?>

  <a href="#nogo" tabindex="-1" class="css_tooltip">?<span><?php echo $htmlOptions['tooltip']; ?></span></a>

<?php endif; ?>



(tabindex="-1" to prevent from focusing)

using CSS:




a.css_tooltip{

	font-size: 11px;

	padding-left: 4px;

	position: relative; /*necessary to position next the span in an absolute way*/

	text-decoration: none;

}


a.css_tooltip span{

	display: none; /*hide the span element in opening*/

	border-radius: 5px;

	-moz-border-radius: 5px;

	-webkit-border-radius: 5px;

	-moz-box-shadow: 0 1px 2px rgba(0,0,0,0.5);

	-webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.5);

}


a.css_tooltip:hover{

	font-size: 11px;

	padding-left: 4px;

}


a.css_tooltip:hover span{

	background-color: #FFFFFF;

	border: 1px solid #777777;

	color: #000000;

	display: block; /*the span element are converted from inline to block element*/

	left: 2em; /*style of the css tooltip*/

	padding: 5px;

	position: absolute; /*absolute positioning in rapport to their parent link*/

	top: 1.4em;

	width: 190px;

	z-index: 90000; /*needed to position the element span above other links*/

}



Demo:

http://www.synet.sk/extra/demo-tooltip.html

Cheers

Lubos

Or perhaps more suitable




CHtml::Tooltip('Enter only <strong>numeric</strong> characters.', array(

  'css' => 'css_tooltip',

  'content' => 'raw',

));