 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
Viral
Joined: 10 Jun 2008 Posts: 8
|
Posted: Tue Jun 10, 2008 10:55 pm Post subject: HELP with Tableless Renderer |
|
|
I am trying to make a form at work, and I am kind of stuck. I am using HTML Quickforms, and also using the tableless renderer.
I wanted to know if there is a way to have multiple form elements in one line
i e, is there a way, I can have City, State, Zip, Country all in one particular line?
Any help will be highly appreciated
My current code is
<html>
<head>
<meta http-equiv="Content-Type" content="text/html"
charset="UTF-7">
<title>Getting Name and Phone Number</title>
</head>
<body>
<?php
#File used for connecting to the Mysql database
include("dbconnect.php");
#/home/virald/public_html/pear/PEAR
ini_set('include_path', "/home/virald/public_html/pear/PEAR:/usr/share/pear");
require_once "HTML/QuickForm.php";
#Using the tableless renderer
require_once "HTML/QuickForm/Renderer/Tableless.php";
require_once "HTML/QuickForm/Controller.php";
$form = new HTML_QuickForm('firsttest', 'post');
$renderer = new HTML_QuickForm_Renderer_Tableless('firsttest');
# Add all the necessary elements into the form
# Add rules for validation and required fields
$form->addelement ('header', 'header', 'Please Enter the information asked for in the form!');
$form->addelement ('header', 'header', 'Section I: Personal Information');
$form->addelement ('text','First_Name', 'First Name');
$form->addrule ('First_Name','Please enter your first name','required');
$form->addelement ('text','Middle_Name', 'Middle Name');
$form->addelement ('text','Last_Name', 'Last Name');
$form->addrule ('Last_Name','Please enter your last name','required');
$form->addelement ('text','Birth_Date', 'Birth Date(mm/dd/yyyy)');
$form->addrule ('Birth_Date','Please Enter your Date of Birth','required');
$Gender = array(' ','Male','Female');
$form->addelement ('select','Gender', 'Gender: ', $Gender);
$form->addrule ('Gender','Please State your Gender','required');
$form->addelement ('text','SSN','Social Security Number');
$form->addrule ('SSN','Please enter your Social Security Number(xxxxxxxxx)','required');
$form->addrule ('SSN','Please enter your Social Security Number(xxxxxxxxx)','numeric');
$form->addelement ('text','Stree_Address','Street Address');
$form->addelement ('text','City','City');
$form->addelement ('text','State','State');
$form->addelement ('text','Zip_Code','Zip Code');
$form->addelement ('text','Country','Country');
$form->addelement ('text','Home_Phone_Number', 'Home Phone Number');
$form->addrule ('Home_Phone_Number','Please enter a valid phone number (Ex. 1234567890)','numeric');
$form->addelement ('text','Cell_Phone_Number', 'Cell Phone Number');
$form->addrule ('Cell_Phone_Number','Please enter a valid phone number (Ex. 1234567890)','numeric');
$form->addelement ('text','Email','Email');
$form->addRule('Email','Please enter a valid email address (Ex. example@exam.com)', 'email');
$form->addRule('Email','Please enter a valid email address (Ex. example@exam.com)', 'required');
$US_Citizenship = array(' ','YES','NO');
$form->addelement ('select','US_Citizenship','US Citizenship: ',$US_Citizenship);
$form->addrule('US_Citizenship','Please State your Citizenship status','required');
$form->addelement ('header', 'header', 'Section II: College Information');
$form->addelement ('submit', 'btnsubmit', 'Submit Entry');
# Trim all the unneccessary spaces on either side of the words
$form->applyfilter ('_ALL_','trim');
$form->removeattribute('name');
if ($form->validate()) |
|
| Back to top |
|
 |
Viral
Joined: 10 Jun 2008 Posts: 8
|
Posted: Wed Jun 11, 2008 1:16 am Post subject: continuing my original post |
|
|
I have tried grouping multiple elements, but they dont let me add things in front of it, to label those elements.
therefore, I am stuck with this code
any help would be great,
this code has few more lines, all they do is validate the code and display it, not the most important part of the form
thanks a lot
~Viral |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1011
|
|
| Back to top |
|
 |
Viral
Joined: 10 Jun 2008 Posts: 8
|
Posted: Wed Jun 11, 2008 9:01 pm Post subject: |
|
|
Hey Mark
thanks a lot for the reply
I am still stuck as I am having trouble using the $seperator command.
Is there a example I could see which uses addgroup() and $seperator?
an example would help me a lot
thanks a lot again |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1011
|
|
| Back to top |
|
 |
Viral
Joined: 10 Jun 2008 Posts: 8
|
Posted: Wed Jun 11, 2008 10:13 pm Post subject: |
|
|
Thanks a lot mark,
now I think, I am getting where I need to get, not there yet, but on my way
Is is possible to use Tableless Renderer, and have the information in the $separator display on top of the Element, or will it always be right before the element |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1011
|
Posted: Wed Jun 11, 2008 10:28 pm Post subject: |
|
|
| Viral wrote: | | Is is possible to use Tableless Renderer, and have the information in the $separator display on top of the Element, or will it always be right before the element |
Of course you can change the layout. setElementTemplate() allows this:
http://pear.php.net/manual/en/package.html.html-quickform-renderer-tableless.html-quickform-renderer-tableless.setelementtemplate.php
Just copy the string of the $_elementTemplate property from the tableless renderer source file, modify it for your needs, and call setElementTemplate() with this new string. The second parameter allows to restrict the application of the new layout to one or more elements. |
|
| Back to top |
|
 |
Viral
Joined: 10 Jun 2008 Posts: 8
|
Posted: Thu Jun 12, 2008 9:20 pm Post subject: Another problem |
|
|
Hey everyone
Now, i have a new problem, I need to set the width of the Element I make in form.
I know there is a way to do it, i think, but there is no way I can figure out to do it.
Any help will be appreciated
all i need to do is control the width of each element in the form
thanks a lot
~Viral
P S thanks mark for your earlier help |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1011
|
Posted: Thu Jun 12, 2008 9:22 pm Post subject: |
|
|
You're looking for the $attributes parameter that each element has. Simply pass an array like | Code: | | array('style' => 'width: 300px;'); | to it. |
|
| Back to top |
|
 |
Viral
Joined: 10 Jun 2008 Posts: 8
|
Posted: Thu Jun 12, 2008 9:32 pm Post subject: |
|
|
hey, thanks mark
That is what I was looking for
thanks again
but where do I put it in the Form->addelement command?
Sorry for having soooooo many small silly questions |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1011
|
Posted: Thu Jun 12, 2008 9:34 pm Post subject: |
|
|
| Viral wrote: | | but where do I put it in the Form->addelement command? |
That depends on the element, some have more, some have fewer parameters. If you look into HTML_QuickForm docs for each element, you'll find the constructor's parameters there. addElement() basically only calls these constructors, depending on the first parameter (e.g. 'text'). Therefore, the number in addElement() is one position higher than in the element's constructor. |
|
| Back to top |
|
 |
Viral
Joined: 10 Jun 2008 Posts: 8
|
Posted: Thu Jun 12, 2008 10:51 pm Post subject: |
|
|
thanks mark for all your help
I have finally made the form |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|