How to set width and height of text field in cakephp

cakephpstyles

In my application, I need to take input from the user for a column named 'body' in a table in the database.

My code in the .ctp file is:

echo $form->input('body',array('style'=>'width: 900px'));

In this way, i am able to specify the width of the body field which works fine. But, I want to specify the height as well.

I tried echo $form->input('body',array('style'=>'width: 900px height: 500px'));
echo $form->input('body',array('style'=>'width: 900px','style'=>'height: 500px'));

The first one doesnt work for either width or height and the second one modifies only the height but not the width.
Can someone please tell me how to overcome this issue.

Thank you very much in advance.

Best Answer

// in a css file.
.txtArea { width:900px; height:500px; }

// in your view
echo $form->input('body', array('class'=>'txtArea'));

would be the recommended and preferred manner.

Alternatively, make sure your inline CSS is correct:

echo $form->input('body', array('style'=>'width:900px; height:500px;'));

Your code appears to be missing a ;, and of course by specifying style twice you will be overwriting the previous value.

Related Topic