Welcome Guest, Not a member yet? Register   Sign In
[Solved] Question on Form Helper Generated Source
#1

[eluser]Zach Nolan[/eluser]
Hi All,

This is my first post on this forum and hopefully it's a pretty easy question. I'm utilizing the form helper for a project and when I view the source on the generated page the form code is all on one line. Is there anyway to make each input on a new line when viewing the source code?
#2

[eluser]bretticus[/eluser]
Are you using a view? You should be able to just hit return and write another call to form_input() etc.
#3

[eluser]Zach Nolan[/eluser]
I am using a view. Here is the code I'm using:

Code:
<div id="search">
    
    &lt;?php
    echo form_open('dontplateme/search');
    echo form_input('plate', set_value('plate'));
    echo form_submit('submit', 'Search');
    echo form_close();
    ?&gt;
    
    <p><a href="#" id="submitPlate">Submit A Plate</a></p>
</div>

This is the source it generates:

Code:
<div id="search">
    
    &lt;form action="http://localhost:8888/License Plate/index.php/dontplateme/search" method="post"&gt;&lt;input type="text" name="plate" value=""  />&lt;input type="submit" name="submit" value="Search"  /&gt;&lt;/form>    
        <p><a href="#" id="submitPlate">Submit A Plate</a></p>
</div>

I would like for the source to look cleaner with all the form elements on their own line. Thanks for the quick reply!
#4

[eluser]tonanbarbarian[/eluser]
Code:
echo form_open('dontplateme/search')."\n";
you could also put each call inside its own php code block i.e.
Code:
&lt;?php echo form_open('dontplateme/search');?&gt;
&lt;?php echo form_input('plate', set_value('plate')); ?&gt;
however that puts extra overhead on the server as PHP must switch in and out of PHP processing.

really you are only doing this for 1 person, yourself.
the only time it is really helpful is if you have to debug
if you dont worry about it and let it all go on one line it means marginally less data per page that is transmitted back and forth.
browser will all render the content the same either way and how many people apart from you are ever going to view the source in the page

personally I have gone back and forth over the years with sometimes going through phases of wanting my html source to look nice and other times not minding because i know the extra spaces, linebreaks and tabs are just extra data that serves no purpose.

just an opinion
#5

[eluser]Zach Nolan[/eluser]
Thanks tonanbarbarian! I've gone back and forth with it as well, but I guess I'm just a little OCD =). Thanks for all the help!




Theme © iAndrew 2016 - Forum software by © MyBB