Skip to main content
MorningSleeper
Participating Frequently
May 31, 2017
Answered

Why does code formatting add line breaks and tabs inside textarea that contains php?

  • May 31, 2017
  • 2 replies
  • 7501 views

If I have the following formatted as it is as I don't want any extra spaces inside the textarea:

<textarea name="someVariable" id="someVariable" rows="10"><?php echo $someVariable; ?></textarea>


I want to do code formatting on entire document but it turns above into:

          <textarea name="someVariable" id="someVariable" rows="10">
               <?php echo $someVariable; ?>

          </textarea>


which adds unwanted white space inside the textarea field. It adds a line break, 3 tabs, line break, two tabs inside the textarea. How can I prevent this from happening while still being able to use code format?

I looked in the Edit > Preferences > Code Format > Tag Libraries > HTML tags > textarea and have:

Line Breaks: No Line Breaks

Contents: Not Formatted

I looked in the Edit > Preferences > Code Format > Tag Libraries > PHP tags I have the following for everything:

Line Breaks: No Line Breaks

This topic has been closed for replies.
Correct answer Niharika Jha

Hi,

I was able to get the issue correctly this time, we will fix this soon for textarea, although we would need to find out more tags where there are spaces getting applied explicitly (if any exist).

As stated earlier, the customization for PHP source formatting can't be done through tag libraries that is why in a php file if you are applying any rule that will be ignored in this case.

So, now we have a bug and an enhancement request.

Regards,

Niharika Gupta

Adobe Dreamweaver

2 replies

Niharika Jha
Adobe Employee
Adobe Employee
June 2, 2017

Hi,

We did not support "PHP Code Formatting" in CC 2015, there was only HTML Code Formatting supported in that version so your php code would never move/change from what is written,that means you can not take it as the baseline for comparison.

Since Code Formatting is a convention and not a standard, it varies from user to user and editor to editor. Until and unless, the option- "Apply Source Formatting" doesn't break your syntax, it is not a bug and in your case it doesn't.  We have always given an option to customize how formatting should apply for HTML through tag libraries, so what we can now do is we can give an option to customize it for PHP as well.

I have already shared this enhancement request with the team, will see if this can be picked up for fixing.

Regards,

Niharika Gupta

Adobe Dreamweaver

MorningSleeper
Participating Frequently
June 2, 2017

I may not have explained this properly, let me try and clarify.

Seems to me either the spaces being inserted inside the textarea form field when I click Edit > Code > Apply Source Formatting are being applied due to formatting defined in the tag libraies for HTML textarea or PHP echo.

For HTML at Tools > Tag Libraries > HTML tags > textarea I have:

Line Breaks: No Line Breaks

Contents: Not Formatted

yet issue still appears, should it have been corrected with those settings?

For PHP at Tools > Tag Libraries > PHP tags > php echo

I have php echo and all other PHP tags set to No line breaks which shows text<?php echo ... >text as the example which is what I want (well actually I want <textarea><?php echo ... ?></textarea> if it makes a difference so maybe this is what is not supported?), yet it still inserts the breaks before and after the php code when inside a textarea. Should it have been corrected with those settings?

Niharika Jha
Adobe Employee
Niharika JhaCorrect answer
Adobe Employee
June 5, 2017

Hi,

I was able to get the issue correctly this time, we will fix this soon for textarea, although we would need to find out more tags where there are spaces getting applied explicitly (if any exist).

As stated earlier, the customization for PHP source formatting can't be done through tag libraries that is why in a php file if you are applying any rule that will be ignored in this case.

So, now we have a bug and an enhancement request.

Regards,

Niharika Gupta

Adobe Dreamweaver

Jon Fritz
Community Expert
Community Expert
May 31, 2017

Is this in CC2017 or an older version?

Is this after you use the Apply Source Formatting option, or is it being generated by the auto-indentation function as you add the code?

MorningSleeper
Participating Frequently
May 31, 2017

In CC2017, when I write the code it stays as desired but after going to Edit > Code > Apply Source Formatting (which I want to do for the rest of the document) it adds the white space.

Jon Fritz
Community Expert
Community Expert
May 31, 2017

Apparently, the Brackets code editor knows better than both of us.

I can confirm the same incorrect formatting on Apply Source Formatting with the settings and code you've used.

CC2015 works correctly, CC2017.1 re-formats with incorrect line breaks and indentation.