Often you want to give the user info about inputfields, you never no when the user want the information so i want to give the user information via the title attribute on every label.
One way to this is like:
<?php echo $form->labelEx($model,'extra',array('title'=>'Info to user...')); ?>
But then you have to write it all over for each label. I would to have the titel attribute like attributeLabels in model. Or even better, have default htmlOptions per column, like:
In model:
public function htmlOptions()
{
return array(
'id' => array('title'=>''),
'extra' => array('title'=>'In this field...'),
...
);
)
Its possibel to build this logik in the framework but i dont want to change the framworks files.
My idea is to extend the form class, eg. CActiveForm, extend this class and override the label and labelEx methods:
class ActiveForm extends CActiveForm
{
public function label($model,$attribute,$htmlOptions=array())
{
if (method_exists($model, 'attributeHtmlOptions'))
{
$arrHtmlOptions = $model->attributeHtmlOptions();
if (isset($arrHtmlOptions[$attribute]))
$htmlOptions = $arrHtmlOptions[$attribute];
}
return CHtml::activeLabel($model,$attribute,$htmlOptions);
}
}
Then you can write attributeHtmlOptions method in your model like you said in your first post, and in the view you use ActiveForm widget instead of CActiveForm.