Text Area on form value stretching out view

Hello everyone,

I am having an issue when imputting text into a form into the following field…


		<?php echo $form->labelEx($model,'issues'); ?>

		<?php echo $form->textArea($model,'issues',array('rows'=>10, 'cols'=>20,'size'=>150,'maxlength'=>600), array(

		)); ?>

		<?php echo $form->error($model,'issues'); ?>

Upon entry of the form, the text displayed in the view does not ever line break, an continues to strech out the page for the legnth of the entry and messes up formatting. How can I allow a text area to operate like a textfield and include new lines?

I’m not sure about some of the stuff you have in that line of code. What is ‘size’=>150 and the array at the end?


<?php echo $form->textArea($model,'issues',array('rows'=>10, 'cols'=>20)); ?>

Replace with the line above and see what happens.

Hi. What’s the array() for? See the CActiveForm::textArea() documentation, it does not have such syntax.

So try like this:


<?php echo $form->textArea($model, 'issues', array('rows'=>10, 'cols'=>20, 'size'=>150, 'maxlength'=>600)); ?>

If it doesn’t work, try with a simpler code:


<?php echo $form->textArea($model, 'issues'); ?>

When it works, you’ll want maybe to fox the size on your text area:


<?php echo $form->textArea($model, 'issues', array('style' => 'resize:none')); ?>

I thought this had fixed the issue? However, I am still not having new line breaks occur?

Is there a way I can specify how many characters I would like there to be on one line before an auto linebreak in the value submitted?

If what you want is automatic line breaks after a certain number of characters (?) I’m pretty sure it is not provided in standard, but some jQuery could help.

Anyway, a text area is a pretty dumb HTML element. Maybe you could check rich-text (WYSIWYG) editors…

Otherwise, could you explain your usage scenario?

I have a few forms where there is text boxes for optional comments of about 500 characters or less. I don’t technically need special formatting? maybe the ability to (bold,italics,strikethrough,paragraphs, and links?) But thats it. However, I am confused as how I can allow this special formatting to appear in views and detailed views, instead of just <p> <b> etc showing up?

I’ve looked into ecke editor extension and tried to utilize it as so. However, still having the issue as mentioned above.


		<?php $this->widget('application.extensions.eckeditor.ECKEditor', array(

                'model'=>$model,

                'attribute'=>'issues',

                'config' => array(

                    'toolbar'=>array(

                        array( '-', 'Bold', 'Italic', 'Underline', 'Strike' ),

                        array( 'Link', 'Unlink') ,

                    ),

                  ),

 

                )); ?>

I don’t see why your words aren’t wrapping. It’s the default behaviour even on extremely long words. Perhaps some css is causing it.

Try adding this style:


<?php echo $form->textArea($model, 'issues', array('style' => 'resize:none; word-wrap:break-word;')); ?>

If that doesn’t fix it, you can force wordwrap with php:


$wrappedString = wordwrap($longWordString, 30, "\n", true);

The line above will cut a long word at 30 characters and insert the newline character.

EDIT:

Be aware that you might want to strip out those newline characters when saving back to database. str_replace() will help you there.

Not sure why it wasn’t before. But this seems to have fixed it!

Thanks!

Hey, I have a similar issue.

I have a text field inside a <td> but the line of text just keep going, this is my code:




<td rowspan=3; width="20%">

				<?php echo $form->labelEx($model,'notes'); ?>

				<?php echo $form->textField($model,'notes',array('maxlength'=>100,'style'=>'height:200px; display:inline;')); ?>

				<?php echo $form->error($model,'notes'); ?>

			</td>



I just can’t mget the text begins on top and break for it to fix on the field.

Thanks for your help(:

I solve it!!!

Kind’a lame, I noticed that my field was a Text field, and when I apply your options didn’t work because yours are textArea!! Duh. Well, thanks anyway!!

Good Vibes ^_^