Reputation: 20555
I have the following input field in a form:
echo $this->Form->input('website_name');
Now i want it to display a prompt text that when the user starts to type disapears
i have tried the following:
echo $this->Form->input('website_name'),array('namespace'=>'Hello world');
echo $this->Form->input('website_name'),array('title'=>'Hello world');
echo $this->Form->input('website_name'),array('placeholder' =>'Hello world');
but with no luck. Does anyone know how to get a prompt text on these text fields?
Upvotes: 0
Views: 331
Reputation: 4835
input()
is a cakePHP method and you are trying to put 2 attributes but wrong. Here is correct form:
echo $this->Form->input('website_name', array('placeholder'=>'Hello world'));
'website_name'
array('placeholder'=>'Hello world')
Upvotes: 0
Reputation: 7447
This is exactly what you want:
echo $this->Form->input('website_name', array('placeholder' => 'Hello world'));
Upvotes: 1
Reputation: 6736
You can use placeholder
instead of name and title.
echo $this->Form->input('website_name',array('placeholder'=>'Hello world'));
Upvotes: 1
Reputation: 27364
Your declaration is wrong.
echo $this->Form->input('website_name'),array('namespace'=>'Hello world');
--------------------------------------^^--
echo $this->Form->input('website_name'),array('title'=>'Hello world');
--------------------------------------^^--
must be
$this->Form->input('website_name'
array('namespace'=>'Hello world',
'title'=>'Hello world',
'placeholder' =>'Hello world'));
Upvotes: 1