Kaya 0.5.2 reference for Webapp::autoFill

List of functions and data types in Webapp

Void autoFill(ElementTree form, DataSource mainvars, Dict<String, [String]> extravars=Dict::new())

Arguments

Usage

Automatically fill a HTML form based on data from a particular data source. This makes it easy to construct web forms with error handling - see the webapp tutorial for more information.

ElementTree OnHello(Int dummy) {
    div = anonymousBlock; // we create this temporarily.
    fname = incomingValue("fname",DataPost);
    lname = incomingValue("lname",DataPost);
    if (fname != "" && lname != "") {
        p = addParagraph(div,"Hello "+fname+" "+lname);
        return p;
    } else {
        form = HelloForm();
// if they entered one of first and last name, make sure it's still in the form
        autoFill(form,DataPost);
        return form;
    } 
}

ElementTree helloForm() {
    parent = anonymousBlock;
    form = addLocalForm(parent);
    f1 = addFieldset(form,"Who are you?");
    input = addLabelledInput(f1,"Your First Name",InputText,"fname","",0);
    input = addLabelledInput(f1,"Your Last Name",InputText,"lname","",0);
    submit = addLocalControlInput(f1,"Say hello",OnHello,1);
    return form;
}

Related

kaya@kayalang.org | Last modified 29 November 2011 | Supported by Durham CompSoc | Powered by Kaya