Layout.php

Layout-php is a php class that allows to create forms in very little time. The main goal is to have a description of the fields I want in the script that should be as easy to understand as possible (html is not at all like that!), so tat code can be read in a simple and fast way. Forms at the moment are created with tables. Main target:

This is a sort of porting of my package layout in php. It helps you write forms in php in a snap. I developed it while writing some modules for webmin.

The main advantage is it allows to use the same formalism as layout-tcl, your php will be much cleaner, and up to now I didn't find a situation in which it could not do what I wanted ;-)

A first example

Suppose you want to show a form to gather information on people:

general information
first name
last name
address
male
female
hobbies
mountain sky
surf
music
theatre
Action
$lay = "
        #- general information
        first_name 
        last_name
        address  -
        r=male/sex   r=female/sex
        #- hobbies
        c=sky   c=surf   
        c=music c=theatre
        #- Action
        s=send     
";
$a = new Layout($lay, "action=to_be_written.php","align=left");

$Form["first_name"] = "Sandro";
$Form["last_name"] = "Dentella";
$Form["sex"] = "male";
$Form["mountain_sky"] = "on";

tips_init("src=/js/freetips.js", "css=/css/helptip.css","type=mau");
$Tip["e-first_name"] = "I always forget which is my first name...".
    "look at how I set the default";
$Tip["e-last_name"] = "is this the family name?";
$Tip["r-female/sex"] = "The nice, pretty,...";
$form = $a->create();

The class

It is mainly a php class (layout) with some methods:

You need to configure all what you want before invoking create/show method. This is becouse all configuration is done by filling values in arrays that will be tested the moment you create the code.

You can also use an array (Tip) to set help tips on field. You can have a look at a more exaustive example here

Limits

syntax

Layout has been built around some needs I had, so it may not cope with all possible situations, you are encouradged to send me suggestions to improve it. It is still an alpha release in the sense that I'm not sure the adopted formalism will be the final one, ie: future releases may change the syntax of the definizion of the layout.

javascript

The javascript code ship with this package is needed to show tooltips when you pass with the mouse on fileds to whisch a $Tip was declared. I ship two different file, one is at the moment more accurate, but has a license that is GNU only for GNU project or non commercial (http://webfx.eae.net). The other is completely free. It is up to you to decide which one you prefere. The very free one was written by a friend Maurizio Pedrazzoli that didn't have the time to refine it yet, I will integrate a new version as soon as he will have one. You can switch between different types just

Download

You can download it from here. Last version is 0.1.