Skip to content

Inputs missing in form when using 'startval' #153

@SebT

Description

@SebT

When I generate a form with no 'startval' property it works perfectly, all properties specified in the schema can be set via the form.

But if I want to edit an existing object (by using 'startval''), the properties of the schema that are not defined for the existing object don't generate inputs.

For instance if I have this schema:

{
  type: "object",
  properties: {
    test1: {type: "string"},
    test2: {type: "string"},
    test3: {type: "string"}
  }
}

And I generate a form with startval equal to {test2: "testing"} there is no input for 'test1' and 'test3', I can only edit 'test2'.

How to fix this please?

EDIT: I went through the source code and found this object editor's setValue function:

// First, set the values for all of the defined properties
    $each(this.editors, function(i,editor) {      
      if(typeof value[i] !== "undefined") {
        // If property is removed, add property
        if(editor.property_removed) {
          self.addObjectProperty(i);
        }

        editor.setValue(value[i],initial);
      }
      else {
        // If property isn't required, remove property
        if(!initial && !editor.property_removed && !editor.isRequired()) {
          self.removeObjectProperty(i);
          return;
        }

        editor.setValue(editor.getDefault(),initial);
      }
    });

self.removeObjectProperty(i); is the problem here. Can you please add an option to disable this and don't remove editors for which the 'startvat' object has no value?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions