Answers to Frequently Asked Questions regarding CForms

Meta-FAQ - Questions and Answers about the CForms FAQ itself

Can I post a question without an answer in the FAQ?

Yes, that's perfectly alright. In fact, you could post them right here:

Who is maintaining this FAQ?

I am, you are, he/she/it is. We all do it. Feel free to post questions or to answer them, in a polite and cooperative spirit.

CForms Styling

Q. How do I remove the "views" links from the top right of forms?

A. Your answer here :)

Q. What are some useful CForm links?

A.

CForms/Flow/Sitemap

Q. How do I use Forms without the handleForm function

A. Call your custom flowscript function from the sitemap. The sitemap and funciton might look as follows:

Flow script:

function myFormFlow(){
        var documentURI = "path/to/your/xml_do_to_bind_to.xml";
        var form = new Form("path/to/your/form_def.xml");
        var dom = loadDocument(documentURI);
        var viewData = new Object();
        viewData.selectOptionList = new Array();
        viewData.selectOptionList.push( {value: "1", label: "option 1" });
        form.createBinding("path/to/your/form_bind.xml");
        form.load(dom);
        form.showForm("form-display-pipeline",viewData );
        form.save(dom);
  ...
}

Site Map:

    <map:match pattern="the_form">
        <map:call function="myFormFlow"/>
    </map:match>

Segment of form def field with options defined in flow:

    <fd:field id="class" required="true">
      <fd:label>Select an option:</fd:label>
      <fd:datatype base="string"/>
                        <fd:selection-list dynamic="true" type="flow-jxpath" list-path="selectOptionList" value-path="value" label-path="label"/>
    </fd:field>

Where does it go?

Q. Where can the form data go once it's been successfully accepted, and how do you do it?

A. ??? (needs an answer)

Obvious requirements would include:

  1. sent by email to some address
  2. added to a database as a new record
  3. saved on the server in a new XML file (this one is really important)

  4. saved on the server as an additional instance of a second-level element in an existing XML file (ie inserted immediately before the end-tag of the root element)
  5. used to replace (update) matching elements in an existing XML file (assuming the form had been populated at display time with the data from the existing file)
  6. submitted as data to some external (non-Cocoon, non-Apache, probably non-Java) program (script or binary executable)

CFormsFAQ (last edited 2009-09-20 23:40:59 by localhost)