The fastest easiest way to get it right.

Making An HTML Form

HTML Forms can be made by the same process that we use to generate all other HTML elements. We start out with a top-level HTML node and then at some point at the FORM node in.

The example below creates a very basic form:

class x6example extends androX6 {
    function x6main() {
        $top = html('div');
        $top->h('h1','Please Fill Out the Form');

        # The form() method hands you back a form that is
        # is named "Form1", has method "POST" and action
        # "index.php".
        $form = $top->form();
        # This is very important! Without this the form will
        # not post back to this page!
        $input = $form->h('input');
        $input->hp['name'] = 'anyvalue';
        $input = $form->h('input');
        $input->hp['type'] = 'Submit';
        $input->hp['value'] = 'Submit Now';

The first two lines should be very familiar by now, they simply create a top-level node and add a title H1 to it.

The third line is a shortcut for creating a FORM element and setting its three required properties. Because we passed in no parameters, the form will be named "Form1", it will have method of "POST", and it will submit to the page "index.php".

Line four completes the picture. It creates a hidden variable that names the x6page that Andromeda's index.php should hand execution to. When an x6page value is not provided, execution always falls back to the x_welcome.php or x_login.php page.

Setting Different Parameters

We can of course choose different value for any of the parameters. The parameters of the form() method are:

  • Name - the name of the form (default Form1).
  • Method - HTTP method, default POST.
  • Action - PHP page, this should almost always be left null so the default index.php will be called.
  • x6page - the x6page to call, defaults to none.

If you supply the fourth parameter, then you do not need a hidden variable to specify the value of x6page. This code:

$div = html('div');

#  This creates a form named "myForm", using HTTP method GET,
#  and specifying x6page of "example"
$form = $top->form('myForm','GET',null,'example');


Will render the following HTML:

comments powered by Disqus
Home |  Documentation |  Download |  Credits |  Contact |  Login
Andromeda © Copyright 2004-2013, Licensed under the GPL Version 2