Marc Rasmussen
Marc Rasmussen

Reputation: 20555

Cakephp input prompt text

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

Answers (4)

Lkopo
Lkopo

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'));
  1. string - 'website_name'
  2. Array - array('placeholder'=>'Hello world')

Upvotes: 0

Vahid Hallaji
Vahid Hallaji

Reputation: 7447

This is exactly what you want:

echo $this->Form->input('website_name', array('placeholder' => 'Hello world'));

Upvotes: 1

Devang Rathod
Devang Rathod

Reputation: 6736

You can use placeholder instead of name and title.

echo $this->Form->input('website_name',array('placeholder'=>'Hello world'));

Upvotes: 1

Dipesh Parmar
Dipesh Parmar

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

Related Questions