Re: [Phplib-users] show_element doesn't present value?
Brought to you by:
nhruby,
richardarcher
From: Frank B. <fb...@sy...> - 2001-12-12 11:58:50
|
Thanks for the tip about webmonkey site. I have written numous webpages with databases and forms, but I thought it was time to do it "correctly". When I read about the form object in phplib, I realised it had the potential to put everything releated to each element together in one place. What I am trying to do is create a page with numerous (almost) identical forms. The only difference between the various forms is that each one will present different values. I thought that I could just create a single form object and then present it several times with different values. When I look at the code for show_element, it appears to accept the $value arg for all element types. I have read "show_element" docs several times and perhaps I don't understand the significance of "Usually, the second argument is not used." Does this mean that for some element types, the second argument CANNOT be used? If this method is much more restrictive than I first thought, how do I determine which elements cannot use the second argument? >If you want to show a value by default you better include it as part of >your add_element() call Are you just trying to be nice, or do you really mean "you MUST include it as part of your add_element() call"? I can see how re-arranging the code to assign value during add_element call would work; but it just seems like a nasty way to write the code. Do I really HAVE TO HAVE a new form object for every occurence of a form on my webpage, or can I create a form object once and simple present it numerous times with different data each time? Perhaps phplib-7.2d/pages/admin/new_user.php3 should be written to use the form object? Actually, that's exactly what I'm trying to do! I thought I would start with a simple exercise. If re-writing this script to use form object, is is possible to do so with my "$f = new form;" preceeding the while statement that traverses the result set, or MUST the form object be created each time through the loop? Frank At 11:16 AM 12/12/01 +0200, Lazaro Ferreira wrote: >According to Lib.. documentation > >"show_element($name,$value) > >Outputs the form element named $name. Usually, the second argument is not >used. It is always necessary for radio elements and checkbox elements with >the multiple attribute set, since many of these may have the same name. It >also must be used for submit elements to label the submission button; the >value attribute is not used for submit elements. For other elements that may >be array valued (notably text elements) multiple calls to show_element will >show successive values." > >If you want to show a value by default you better include it as part of >your add_element() call > >I would recommend you to use tpl_form class to deal with Databases > >tpl_form, is a bit hard to understand at the beginning (at least for me) but >once you have managed to understand it, it provides you a good pattern >design for "databases bounded" forms, you may also (I do), use the >query_sql class, to read and write to MYSQL DB, within tpl_form methods : >process_input(), and process_default(), > >tpl_form and query_sql classes working together may do the trick of "BOUNDED >FORMS", in a MS VB style, but with some limitations, everything is >documented, (see PHPLIB DOC ) > >On the other hand if you want a very straigth forward example of how to to >use DB with FORMS in PHP (without PHPLIB) >go to www.webmonkey.com >look for a PHP tutorial that covers PHP and MYSQL for the begginers, It was >my first PHP reading, ( provided that you have some programming experience ) >you will learn everything you need to implement DB "Bounded" Forms in a few >hours > >Hope this help >Lazaro > > >----- Original Message ----- >From: Frank Bax <fb...@sy...> >To: <php...@li...> >Sent: Wednesday, December 12, 2001 5:44 AM >Subject: [Phplib-users] show_element doesn't present value? > > >> I'm trying to use phplib-7.2d ooh forms for the first time... >> >> $f = new form; >> $f->add_element(array( >> 'type' => 'text', >> 'name' => 'realname', >> 'size' => 12, >> 'maxlength' => 16, >> ) ); >> $f->show_element('realname','xxxx'); >> >> This code generates: >> <input name='realname' value="" type='text' maxlength='16' size='12'> >> >> Why don't I get value="xxxx"? >> >> I want to create a page to maintain a database table. I expect that I >> create my form object once with an element for each field; then loop >> through my data, producing a form for each row? Is this approach wrong? >> >> Frank >> >> _______________________________________________ >> Phplib-users mailing list >> Php...@li... >> https://lists.sourceforge.net/lists/listinfo/phplib-users >> >> >> > > > |