Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to create a dynamic form

    hello all, I am just new by smart client. Maybe someone can help me now. I have to create a "dynamic from", that means, the field (or item ) definition are come from server. my code is like :

    isc.DynamicForm.create({
    ID:"matrixForm",
    numCols:2,
    fields: []
    })


    In one function I try to create the form items like :

    function getMatrixFields(){
    // load the data from server
    ....
    // create the item in a loop
    eventCodeItemArray[i] =
    isc.CheckboxItem.create( {
    name: eventCodeList[i].evnetCode ,
    title: "",
    ....
    });

    // add the item into from
    matrixForm.setFields(eventCodeItemArray);


    }

    then the error message,

    01:33:51.000:XRP8:WARN:DynamicForm:matrixForm:[Class CheckboxItem] form item defined with no 'name' property - Value will not be saved. To explicitly exclude a form item from the set of values to be saved, set 'shouldSaveValue' to false for this item.

    Why it says no "name" property? When I submit the new form,


    I find from the doc that says should never directly create a "FormItem", but How can I create a from item and redefine the from at runtime?

    #2
    Right, you shouldn't instantiate FormItems directly. If you want to change fields on the DynamicForm after creation, call setFields() with an array of object literals that describe the fields.

    For example:

    Code:
    form.setFields([
        {name:"foo", type: "date"}
    ]);
    The other approach is to define a DataSource, then you can rebind any databindable component (like a DynamicForm) to a different set of fields at runtime via setDataSource(). The advantage of this approach is that DataSources are reusable definitions of fields, that you can provide to multiple components.

    Comment

    Working...
    X