Welcome Guest, Not a member yet? Register   Sign In
is this a crazy view for a contact form
#1

[eluser]dsims[/eluser]
Code:
<?php
echo $this->validation->error_string;
$attributes = array(
    'class'       => 'contact'
    );
echo form_open('contact',$attributes);
$this->table->set_heading('','Contact Form');
$data = array(
    'name'        => 'fname',
    'id'          => 'fname',
    'value'       => '',
    'maxlength'   => '20'
     );
$this->table->add_row('<label for="fname">First Name:</label>', form_input($data), '* required');
$data1 = array(
    'name'        => 'lname',
    'id'          => 'lname',
    'value'       => '',
    'maxlength'   => '30'
     );
     $this->table->add_row('<label for="lname">Last Name:</label>', form_input($data1), '* required');
$data2 = array(
    'name'        => 'email',
    'id'          => 'email',
    'value'       => '',
    'maxlength'   => '40'
     );
$this->table->add_row('<label for="email">Email address:</label>', form_input($data2), '* required');
$data3 = array(
    'name'        => 'webad',
    'id'          => 'webad',
    'value'       => '',
    'maxlength'   => '40'
     );
$this->table->add_row('<label for="webad">WebSite:</label>', form_input($data3), '( optional )');
$data4 = array(
    'pse'         => 'howdy',
    'sug'         => 'Site Suggestion',
    'reg'         => 'Regular Advertising',
     );
$this->table->add_row('<label>What do you want to tell us about?</label>', form_dropdown('topic',$data4), '* required');
$data5 = array(
    'name'        => 'comments',
    'id'          => 'comments',
    'value'       => '',
    'rows'        => '7',
    'cols'        => '39'
    );
$this->table->add_row('<label for="comments">
            Your comments:<br/>
            Limit of 250 characters<br/>
     </label>', form_textarea($data5), '* required');
$this->table->add_row('',form_button('submit','Submit'),'');
echo $this->table->generate();
echo form_close();
?&gt;
It looks nice, is this the norm? I think I could have made a dynamic array for the data, values are empty for future dynamics, just following the examples or should I write a function or class for this. Any guidance would help. Thanks Dave
#2

[eluser]Colin Williams[/eluser]
It works, I'm sure, but it doesn't "look nice" in my opinion. I'm not sure I would ever use tables for forms (might be a decent semantic argument for it, but it's certainly not as flexible). Secondly, if a strictly front-end coder/designer saw this, well, they'd probably run screaming.
#3

[eluser]dsims[/eluser]
Yeah i thought it looked ugly. I'm not a big fan of tables either, even thought the registration form for this website is used with tables, and it is an easier layout than having to tweak a css sheet with divs and spans and check all the different web browsers for compliance. I might just write a function or a class that utilizes the form helper and table class. Thanks for your guidance.




Theme © iAndrew 2016 - Forum software by © MyBB