Odd text formatting on edit

I have never had this problem in any previous projects, but for some
reason all text_area inputs that contain a new line result in a huge
indent

ex

|Hello
|World
|
|

results in when editting

|Hello
| World
|
|

I have stripped out all text formatting on record saves, as well as
formating when filling the text box.

Has anyone seen this before?

Thanks

If you aren’t using haml, ignore this.

If you are using haml, this can happen due to how haml formats its
ouput.

To fix this in haml, tweak to your haml statement in the view to use the
tilde instead of an equals when defining text areas, like the proj_text
field below:

%hr/

  • form_for @project do |f|
    %table
    %tr
    %td= Project:
    %td= f.text_field :proj_name, :size => 30
    %tr
    %td Description:
    %td= f.text_field :proj_desc, :size => 120
    %tr
    %td Notes:
    %td~ f.text_area :proj_text, :cols => 90, :rows => 20
    %hr/
    %table
    %tr
    %td= f.submit “Save”

Iso,

If you’re generating the text_area contents from rails you may want to
try
suppressing the new line when closing your ERb phrases like this:

<%= Time.now -%>

instead of

<%= Time.now %>

Just an idea.

Arshak

iso … wrote:

I have never had this problem in any previous projects, but for some
reason all text_area inputs that contain a new line result in a huge
indent

ex

|Hello
|World
|
|

results in when editting

|Hello
| World
|
|

I have stripped out all text formatting on record saves, as well as
formating when filling the text box.

Has anyone seen this before?

Thanks

Ar Chron wrote:

If you aren’t using haml, ignore this.

If you are using haml, this can happen due to how haml formats its
ouput.

To fix this in haml, tweak to your haml statement in the view to use the
tilde instead of an equals when defining text areas, like the proj_text
field below:

%hr/

  • form_for @project do |f|
    %table
    %tr
    %td= Project:
    %td= f.text_field :proj_name, :size => 30
    %tr
    %td Description:
    %td= f.text_field :proj_desc, :size => 120
    %tr
    %td Notes:
    %td~ f.text_area :proj_text, :cols => 90, :rows => 20
    %hr/
    %table
    %tr
    %td= f.submit “Save”

I should have mentioned that I am using Haml this time around. That
fixed the problem.

Thank you very much.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs