By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,706 Members | 1,105 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,706 IT Pros & Developers. It's quick & easy.

framework for creating forms, phplib good, are there any options?

P: n/a
I have been using phplib for a while and I really like the framework
except for form creation. Maybe it is me but I in my opinion there
isn't a good way to create forms or should I say, everything else is
so well done that the way you create forms seems to be too cumbersome,
in particular making it so that a pull down menu selects a value that
you assign it.
In any case, does anyone know of any php based (or other readily
accepted web language) solution to creating forms?

Any suggestions are welcome
Jul 17 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hello,

On 11/09/2004 01:26 AM, gonzalo briceno wrote:
I have been using phplib for a while and I really like the framework
except for form creation. Maybe it is me but I in my opinion there
isn't a good way to create forms or should I say, everything else is
so well done that the way you create forms seems to be too cumbersome,
in particular making it so that a pull down menu selects a value that
you assign it.
In any case, does anyone know of any php based (or other readily
accepted web language) solution to creating forms?


You may want to try this popular forms generation and validation class:

http://www.phpclasses.org/formsgeneration
--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #2

P: n/a
I can recommend PEAR. It's allmost PHPLIB compatible, modular and has a form
creation class.

Regards,

Eric Brongers

"gonzalo briceno" <go************@gmail.com> schreef in bericht
news:5a**************************@posting.google.c om...
I have been using phplib for a while and I really like the framework
except for form creation. Maybe it is me but I in my opinion there
isn't a good way to create forms or should I say, everything else is
so well done that the way you create forms seems to be too cumbersome,
in particular making it so that a pull down menu selects a value that
you assign it.
In any case, does anyone know of any php based (or other readily
accepted web language) solution to creating forms?

Any suggestions are welcome

Jul 17 '05 #3

P: n/a
gonzalo briceno wrote:
I have been using phplib for a while and I really like the framework
except for form creation. Maybe it is me but I in my opinion there
isn't a good way to create forms or should I say, everything else is
so well done that the way you create forms seems to be too cumbersome,
in particular making it so that a pull down menu selects a value that
you assign it.
In any case, does anyone know of any php based (or other readily
accepted web language) solution to creating forms?

Any suggestions are welcome


You could use phpPeanuts, but that will require that you embrace OOP
within the environment (architecture?) of the framework. If you do, it
will not only generate forms with dropdown lists, search dialogs,
checkboxes, and navigational links to related objects, but also convert
datatypes, validate user data, report user data entry mistakes, if no
mistakes modify your objects, save them to MySql, retrieve them, cache
them, search for them, page the results, and generate some default reports.

But OTOH, you need basic OOP knowledge (the website does NOT offer an
entry level course OOP). And still the paradigm leap you have to make
may be a bridge too far. Furthermore you may have trouble integrating it
with existing databases and application code. And once you really get
the hang of it, you are likely to percieve your 'old' code as 'legacy'
that urgently needs refactoring or rebuilding. But OK, if you are
learning rapidly (i believe most people here do) the last will probably
happen anyway ;-)

Greetings,

Henk Verhoeven,
www.phpPeanuts.org.

BTW, there are many more frameworks in php, see
http://www.hotscripts.com/PHP/Script...ork/index.html

Jul 17 '05 #4

P: n/a
Thanks to everyone with replies; I'm looking into your suggestions.
For those that are already using PHPLIB I have the following code to
generate a pull-down menu and have the particular choice <select>ed
assuming that there is a database record with this information. Note
that my code is tab delimited with 2 spaces per tab so if you copy and
paste the code into a text editor everything should look a lot nicer.

1. This is the function(borrowed from php.net) that queries
table.field and produces an array of values for this field ASSUMING
that it is either of enum or set type.

function mysql_enum_values(&$db, $tableName,$fieldName)
{
$result = $db->query("DESCRIBE $tableName");

//then loop:
while($row = mysql_fetch_array($result))
{
//# row is mysql type, in format "int(11) unsigned zerofill"
//# or "enum('cheese','salmon')" etc.

ereg('^([^ (]+)(\((.+)\))?([
](.+))?$',$row['Type'],$fieldTypeSplit);
//# split type up into array
$ret_fieldName = $row['Field'];
$fieldType = $fieldTypeSplit[1];// eg 'int' for integer.
$fieldFlags = $fieldTypeSplit[5]; // eg 'binary' or 'unsigned
zerofill'.
$fieldLen = $fieldTypeSplit[3]; // eg 11, or 'cheese','salmon' for
enum.

if (($fieldType=='enum' || $fieldType=='set') &&
($ret_fieldName==$fieldName) )
{
$fieldOptions = split("','",substr($fieldLen,1,-1));
return $fieldOptions;
}
}

//if the funciton makes it this far, then it either
//did not find an enum/set field type, or it
//failed to find the the fieldname, so exit FALSE!
return FALSE;
}

2. This is the code that goes into the PHP page that uses PHPLIB's
templates and ooforms. We are using blocks to automate creation of
certain form elements.
include "template.inc";
$t1 = new Template();
$t1->set_file("MyFileHandle","pulldowns_blocks.html" );
$defaults = array (
"message" => "Testing the pull down menu option",
"action" => "inquiry_manage2.php",
"search_for" => "Search for an inquiry where the person's name is"
);
$t1->set_var($defaults);
//Pull the 'highest_education' field from the 'Business_Application'
table and show a pull down

$db = new DB_Example();
$result = $db->query("SELECT `highest_education` , `business_plan` ,
`business_age`
FROM `Business_application`
WHERE `ID` =51");

//if($result)
$row = mysql_fetch_assoc($result);

foreach ($row as $element => $value) {
//set the blocks
$t1->set_block("MyFileHandle", "blk_".$element, $element);
//get the choices for Business_application.element to populate the
pull down menu
$choice = mysql_enum_values($db, "Business_application",$element);
//output the pull down menu
foreach($choice as $x)
{
if ($x == $value) {
$t1->set_var($element."_value", "value='".$x."' selected");
$t1->set_var($element."_text", $x);
}
else {
$t1->set_var($element."_value", "value='".$x."'");
$t1->set_var($element."_text", $x);
}
$t1->parse($element, "blk_".$element, TRUE);
}
}
$t1->parse("MyOutput","MyFileHandle");
$t1->p("MyOutput");

3. This is the actual HTML page with the block definitions. Please
note that blocked sections are named 'blk_<element>' and the
corresponding record field is called <element> so that I can parse the
file with the line
$t1->parse($element, "blk_".$element, TRUE);

<table border=0 width="100%">
<tr>
<td>
<SELECT name="highest_education">
<!-- BEGIN blk_highest_education -->
<option {highest_education_value}>{highest_education_text} </option>
<!-- END blk_highest_education -->
</SELECT>
</td>
</tr>
<tr>
<td>
<SELECT name="business_plan">
<!-- BEGIN blk_business_plan -->
<option {business_plan_value}>{business_plan_text}</option>
<!-- END blk_business_plan -->
</SELECT>
</td>
</tr>
<tr><td valign="top">submit</td><td><input name='submit'
value='submit' type='submit'></td></tr>
</table>

Henk Verhoeven <ne**@phppeanutsREMOVE-THIS.org> wrote in message news:<cm**********@news6.zwoll1.ov.home.nl>...
gonzalo briceno wrote:
I have been using phplib for a while and I really like the framework
except for form creation. Maybe it is me but I in my opinion there
isn't a good way to create forms or should I say, everything else is
so well done that the way you create forms seems to be too cumbersome,
in particular making it so that a pull down menu selects a value that
you assign it.
In any case, does anyone know of any php based (or other readily
accepted web language) solution to creating forms?

Any suggestions are welcome


You could use phpPeanuts, but that will require that you embrace OOP
within the environment (architecture?) of the framework. If you do, it
will not only generate forms with dropdown lists, search dialogs,
checkboxes, and navigational links to related objects, but also convert
datatypes, validate user data, report user data entry mistakes, if no
mistakes modify your objects, save them to MySql, retrieve them, cache
them, search for them, page the results, and generate some default reports.

But OTOH, you need basic OOP knowledge (the website does NOT offer an
entry level course OOP). And still the paradigm leap you have to make
may be a bridge too far. Furthermore you may have trouble integrating it
with existing databases and application code. And once you really get
the hang of it, you are likely to percieve your 'old' code as 'legacy'
that urgently needs refactoring or rebuilding. But OK, if you are
learning rapidly (i believe most people here do) the last will probably
happen anyway ;-)

Greetings,

Henk Verhoeven,
www.phpPeanuts.org.

BTW, there are many more frameworks in php, see
http://www.hotscripts.com/PHP/Script...ork/index.html

Jul 17 '05 #5

P: n/a
.oO(gonzalo briceno)
1. This is the function(borrowed from php.net) that queries
table.field and produces an array of values for this field ASSUMING
that it is either of enum or set type.

function mysql_enum_values(&$db, $tableName,$fieldName)
{
$result = $db->query("DESCRIBE $tableName");
[...]


You could use the following query to fetch informations for the
requested field directly:

SHOW COLUMNS FROM $tableName LIKE '$fieldName'

Then parse the returned Type-field.

Micha
Jul 17 '05 #6

P: n/a

"gonzalo briceno" <go************@gmail.com> wrote in message
news:5a**************************@posting.google.c om...
I have been using phplib for a while and I really like the framework
except for form creation. Maybe it is me but I in my opinion there
isn't a good way to create forms or should I say, everything else is
so well done that the way you create forms seems to be too cumbersome,
in particular making it so that a pull down menu selects a value that
you assign it.
In any case, does anyone know of any php based (or other readily
accepted web language) solution to creating forms?

Any suggestions are welcome


I like phpHtmlLib - http://phphtmllib.newsblob.com

The help/documentation is pretty good and there are a number examples you
can
look at.

Mike
--
Mike Walsh - mike_walsh at mindspring.com
Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.