Package proposal - HTML_FormPersister, HTML_SemiParser

From: Date: Mon, 17 Feb 2003 22:02:45 +0000
Subject: Package proposal - HTML_FormPersister, HTML_SemiParser
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-13428@lists.php.net to get a copy of this message
Good morning. I'd like to propose 2 new packages: HTML_FormPersister HTML_SemiParser Complex demonstration: http://php.dklab.ru/FormPersister/t_formpersister.php Output buffer handle test: http://php.dklab.ru/FormPersister/t_handler.php Source codes (by now) http://php.dklab.ru/FormPersister/HTML/ Short overview -------------- Let's consider that we have a script which prints out the form. The action of this form is pointed to the same script. If the user enters some wrong values into fields (for example, forget to enter his name), script must re-print the form WITH ALL VALUES filled before. Of course, error message should be printed too. I call such fields "persisted". It's a very standard problem, I think. The problem is: how to automatically fill all the fields, including checkboxes, radio buttons and rather selects (and select-multiples)? Module HTML_FormPersister does it transparently for application. See example at http://php.dklab.ru/FormPersister/t_handler.php Now supported: - Simple on-the-fly HTML parsing & correcting all the form tag in document. - Automatical setting width, height of all the <img> tags. - Setting default action of <form>. - "Persistemt" fields support for: - input: text, password, checkbox, radio, hidden; - textarea; - select, select multiple; - Support for complex names like a[b][c]. - Support for auto-array fields, example: <input type=checkbox name=chk[] value=1> <input type=checkbox name=chk[] value=2> <input type=checkbox name=chk[] value=3> - Support default values for all fields: <input type=checkbox name=chk[] value=2 default="on"> <input type=text name=txt default="default text"> <input type=radio name=rad value=val1 default="val1"> - Support for "reversed array fields": <select name=sel[] multiple flip> <option value=a>aaa <option value=b selected>bbb <option value=c selected>ccc </select> will produce in $_POST array( b => 1, с => 1 ) If we do not use flip, output will be array(b,c) (automatically post-processing od $_POST etc. if needed) - Support for LABEL attribute: <input type=checkbox label="clock me!"> -> [x]click me! You may clich on label instead of click on checkbox. - Support for ";"-delimited default values: <select name=sel[] multiple default="a;c"> <option value=a>aaa <option value=b>bbb <option value=c>ccc </select> The best method to use - ob_start("..."), I think. The HTML parser is very simple, but fast. For example, it cannot process tags like <img src=i.gif alt="2>1">, but can correctly process - <img src=i.gif alt="2&gt;1">. -- Best regards, Dmitry Koteroff (dk@dklab.ru), chief programmer (http://www.dklab.ru).

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