Zaphod Beeblebrox
Zaphod Beeblebrox

Reputation: 562

CakePHP - Setting up the default value for a Form->input : I want to have a line break, but how?

I have a form input whose default value I want to have as a couple of short paragraphs. eg in my view:

echo $this->Form->input('story', array('default'=>'Thanks for visiting my campaign page. Be sure to check out the links below'));

At the minute that works ok and creates a text box filled with those two sentences, but I'd prefer to have them on two different lines. And also saved in the DB as such so when they're recalled they automatically appear in two paragraphs. I've tried <p> tags etc but they just turn up in the text.

Is there some way to create a line break when setting the default value in the view which will be stored in the DB as a line break etc...?

Upvotes: 5

Views: 17987

Answers (3)

zzirGrizz
zzirGrizz

Reputation: 1

James answer works for me, i set the default value to a variable

    echo $this->Form->input('billing_fname', array('default'=>$currentuserfname));

Upvotes: 0

lightbyte
lightbyte

Reputation: 565

And to complete the answer of James, I would ensure story field is a TEXT or BLOB field in the database. If it's not then I would force the input to be a textarea, because in the input text fields there is no line break.

Upvotes: 0

Erveron
Erveron

Reputation: 1928

Use \n

echo $this->Form->input('story', array('default'=>'Thanks for visiting my campaign page.\nBe sure to check out the links below'));

Upvotes: 10

Related Questions