PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
HELP with Tableless Renderer

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> PEAR
View previous topic :: View next topic  
Author Message
Viral



Joined: 10 Jun 2008
Posts: 8

PostPosted: Tue Jun 10, 2008 10:55 pm    Post subject: HELP with Tableless Renderer Reply with quote

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. [email protected])', 'email');
$form->addRule('Email','Please enter a valid email address (Ex. [email protected])', '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
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Viral



Joined: 10 Jun 2008
Posts: 8

PostPosted: Wed Jun 11, 2008 1:16 am    Post subject: continuing my original post Reply with quote

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
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
mark



Joined: 07 Jan 2007
Posts: 1235

PostPosted: Wed Jun 11, 2008 2:49 pm    Post subject: Reply with quote

The $separator parameter of addGroup can help you to insert text between elements:
http://pear.php.net/manual/en/package.html.html-quickform.html-quickform.addgroup.php
Back to top
View user's profile Send private message
Viral



Joined: 10 Jun 2008
Posts: 8

PostPosted: Wed Jun 11, 2008 9:01 pm    Post subject: Reply with quote

mark wrote:
The $separator parameter of addGroup can help you to insert text between elements:
http://pear.php.net/manual/en/package.html.html-quickform.html-quickform.addgroup.php



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
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
mark



Joined: 07 Jan 2007
Posts: 1235

PostPosted: Wed Jun 11, 2008 9:19 pm    Post subject: Reply with quote

An example with several usages of groups can be found here:
http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm/docs/groups.php?revision=1.2&view=markup
Back to top
View user's profile Send private message
Viral



Joined: 10 Jun 2008
Posts: 8

PostPosted: Wed Jun 11, 2008 10:13 pm    Post subject: Reply with quote

mark wrote:
An example with several usages of groups can be found here:
http://cvs.php.net/viewvc.cgi/pear/HTML_QuickForm/docs/groups.php?revision=1.2&view=markup


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
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
mark



Joined: 07 Jan 2007
Posts: 1235

PostPosted: Wed Jun 11, 2008 10:28 pm    Post subject: Reply with quote

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
View user's profile Send private message
Viral



Joined: 10 Jun 2008
Posts: 8

PostPosted: Thu Jun 12, 2008 9:20 pm    Post subject: Another problem Reply with quote

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
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
mark



Joined: 07 Jan 2007
Posts: 1235

PostPosted: Thu Jun 12, 2008 9:22 pm    Post subject: Reply with quote

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
View user's profile Send private message
Viral



Joined: 10 Jun 2008
Posts: 8

PostPosted: Thu Jun 12, 2008 9:32 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
mark



Joined: 07 Jan 2007
Posts: 1235

PostPosted: Thu Jun 12, 2008 9:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
Viral



Joined: 10 Jun 2008
Posts: 8

PostPosted: Thu Jun 12, 2008 10:51 pm    Post subject: Reply with quote

thanks mark for all your help

I have finally made the form
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> PEAR All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
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



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement