Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

sql

php

cakephp

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...?

like image 491
Zaphod Beeblebrox Avatar asked Jun 07 '11 23:06

Zaphod Beeblebrox


People also ask

How can I get form data in cakephp?

$data = $this->request->data; $someVariable = $data["name"]; Or, you can access any field directly, by using data() accessor: $someVariable = $this->request->data("name"); From this point, you can do anything you want with this variable.

What is FormHelper?

The FormHelper focuses on creating forms quickly, in a way that will streamline validation, re-population and layout. The FormHelper is also flexible - it will do almost everything for you using conventions, or you can use specific methods to get only what you need.


1 Answers

Use \n

echo $this->Form->input('story', array('default'=>'Thanks for visiting my campaign page.\nBe sure to check out the links below'));
like image 150
Erveron Avatar answered Sep 28 '22 15:09

Erveron