0

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?

4 Answers 4

1

You can use placeholder instead of name and title.

echo $this->Form->input('website_name',array('placeholder'=>'Hello world'));
Sign up to request clarification or add additional context in comments.

Comments

1

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'));

2 Comments

worked. although its array('placeholder'=>'Hello world', instead of namespace
sorry i forget to add placeholder in array...now see
1

This is exactly what you want:

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

Comments

0

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')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.