Re: What about javascript

From: Date: Thu, 09 Aug 2001 13:35:49 +0000
Subject: Re: What about javascript
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-1339@lists.php.net to get a copy of this message
le 9/08/01 14:05, Stig Sæther Bakken à ssb@alltheweb.com a écrit : > [Bertrand Mansion <bmansion@mamasam.com>] >> Hi, >> >> Adam Daniel and I are finishing an html form class for PEAR. It is >> more powerful and more complex than the current form class in PEAR >> but I believe users can need both of them depending on their needs. > > Cool. Would it be possible to use and extend the current HTML_Form > API (I mean the API, not necessarily the implementation), or do you > need a different API? Could you post a url to a prototype to the > list? The API is different because we use addElement and createElement to add elements to the form. But we could also create wrapper methods to make addText equal to addElement("text"). This is easy. In our class, everything is an object. If I add a text field to my form, it comes as an object and to display it, I have to call its toHtml method. This means that a form can be seen as a whole or as a multitude of elements.. For example, I can create solo elements like this : $group[] = &HTML_Form::createElement("radio","STATUT","1","Yes"); $group[] = &HTML_Form::createElement("radio","STATUT", "0","No"); and then add them as a group to my form : $form->addElementGroup($group, "Statut:", "STATUT"); or get the html to display them : $htmlString = $group[0]->toHtml(); or even set their value : $group[0]->setChecked("1"); All display methods are handled by wrapper methods which should be overridden by the user even if they can be used as such. Therefore, it is possible to wrap elements with HTML, with template methods, with PEAR Html_Table class, and so on. By elements I mean the form, the caption, the delimiters, the labels, the fields, the buttons, the required fields, the form table. We will setup a link as soon as it is clean and viewable. Element classes still need to be commented... > One of the things I'd like to do with an HTML form class is to connect > it with either DB_storage or Tomas's new DB_row class, so you can > define relationships between forms and database tables. So far I've > only defined a "storageObject" attribute and then I got lost thinking > how it should work... ;-) We have two methods to put values into fields : setDefaults and loadValues. - You can pass an array (key:elementName, value:elementValue) to setDefaults and it sets all elements values. - loadValues on the other hand loads all posted values in their respective elements. To implement a relationship between DB_storage or DB_row, we will need to create a helper class I think. I have the feeling it shouldn't be that difficult but its purpose has still to be defined. Actually, the only problem I had with our HTML_form class is the mixture of javascript generated by our class to validate entries on the client side and the MD5 javascript of PHPlib. I had to remove the client-side validation. But I think this is an isolated problem very specific to PHPlib. More to be seen soon ! Thanks for your patience, Bertrand Mansion Mamasam

« previous php.pear.dev (#1339) next »