Return Key Not Working For Textarea

I have the following textArea in one of my views.

<div class="row">

&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'ref_description'); ?&gt;


&lt;?php echo &#036;form-&gt;textArea(&#036;model,'ref_description',array('rows'=&gt;6, 'cols'=&gt;50)); ?&gt;


&lt;?php echo &#036;form-&gt;error(&#036;model,'ref_description'); ?&gt;

</div>

Why isn’t it able to return a newline when pressing the enter key but instead it’s moving to the following textField?

Or is there a substitute I may use insted of a textArea for a multiline text field?

Hi That is may be because of javascript restriction.

Please checkout your js and reply here… I will help you!.

If possible pls attach screen shots.

Thanks & Regards,

mEAW

It’s in a CAvtiveForm Widget.

The following is the full code.

<div class="form">

<?php $form=$this->beginWidget(‘CActiveForm’, array(

'id'=&gt;'report-references-form',


'enableAjaxValidation'=&gt;false,

)); ?>

&lt;p class=&quot;note&quot;&gt;Fields with &lt;span class=&quot;required&quot;&gt;*&lt;/span&gt; are required.&lt;/p&gt;





&lt;?php echo &#036;form-&gt;errorSummary(&#036;model); ?&gt;





&lt;div class=&quot;row&quot;&gt;


	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'ref_name'); ?&gt;


	&lt;?php echo &#036;form-&gt;textField(&#036;model,'ref_name',array('size'=&gt;60,'maxlength'=&gt;150)); ?&gt;


	&lt;?php echo &#036;form-&gt;error(&#036;model,'ref_name'); ?&gt;


&lt;/div&gt;





&lt;div class=&quot;row&quot;&gt;


	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'ref_description'); ?&gt;


	&lt;?php echo &#036;form-&gt;textArea(&#036;model,'ref_description',array('rows'=&gt;6, 'cols'=&gt;50)); ?&gt;


	&lt;?php echo &#036;form-&gt;error(&#036;model,'ref_description'); ?&gt;


&lt;/div&gt;


&lt;div class=&quot;row&quot;&gt;


	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'ref_quarter'); ?&gt;


	&lt;?php echo &#036;form-&gt;textField(&#036;model,'ref_quarter'); ?&gt;


	&lt;?php echo &#036;form-&gt;error(&#036;model,'ref_quarter'); ?&gt;


&lt;/div&gt;





&lt;div class=&quot;row&quot;&gt;


	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'ref_year'); ?&gt;


	&lt;?php echo &#036;form-&gt;textField(&#036;model,'ref_year'); ?&gt;


	&lt;?php echo &#036;form-&gt;error(&#036;model,'ref_year'); ?&gt;


&lt;/div&gt;





&lt;div class=&quot;row&quot;&gt;


	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'ref_date'); ?&gt;


	&lt;?php echo &#036;form-&gt;textField(&#036;model,'ref_date'); ?&gt;


	&lt;?php echo &#036;form-&gt;error(&#036;model,'ref_date'); ?&gt;


&lt;/div&gt;





&lt;div class=&quot;row buttons&quot;&gt;


	&lt;?php echo CHtml::submitButton(&#036;model-&gt;isNewRecord ? 'Create' : 'Save'); ?&gt;


&lt;/div&gt;

<?php $this->endWidget(); ?>

</div><!-- form -->

Found the solution:

For further help to this question regarding the Yii. What needs to be changed is in the main layout.

There is a javascript code:

[size=“2”][font=“Courier New”] $(‘body’).on(‘keydown’, ‘input, select’ , ‘textarea’, function(e) {

var self = &#036;(this)


  , form = self.parents('form:eq(0)')


  , focusable


  , next


  ;


if (e.keyCode == 13) {


    focusable = form.find('input,a,select,button,textarea').filter(':visible:not(:disabled)');


    next = focusable.eq(focusable.index(this)+1);


    if (next.length) {


        next.focus();


    } else {


        form.submit();


    }


    return false;


}

});[/font][/size]

Remove the textarea from the $(‘body’).on function ONLY!

[size=“2”][font=“Courier New”] $(‘body’).on(‘keydown’, ‘input, select’, function(e) {

var self = &#036;(this)


  , form = self.parents('form:eq(0)')


  , focusable


  , next


  ;


if (e.keyCode == 13) {


    focusable = form.find('input,a,select,button,textarea').filter(':visible:not(:disabled)');


    next = focusable.eq(focusable.index(this)+1);


    if (next.length) {


        next.focus();


    } else {


        form.submit();


    }


    return false;


}

});[/font][/size]