Textfield Prompt Text

Hello guys,

I have this code:


<?php echo $form->textField($model,'title',array('size'=>46)); ?>

and I want to add a default prompt text inside my input field so when the user click in my input the prompt text disappears automatically.

Is there any way to do that?

Regards

change it as following


<?php echo $form->textField($model,'title',array('size'=>46, 'placeholder'=>'your text')); ?>

Thanks man, that works. I just posted another question on the forum, let me know if you can help me ;)

alternatively you can use javascript


16 <?php Yii::app()->clientScript->registerCoreScript("jquery"); ?>

  17 <script type="text/javascript">

  18 

  19 $(document).ready(function(){

  20   $('#id').val("value");

  21   $('#id').focusin(function(){

  22     $(this).val("");

  23   });

  24   $('#id').focusout(function(){

  25     $(this).val("value");

  26   });

  27 });

  28     

  29 </script>