Skip to content

Form doesn't refresh when setting the schema and form to empty #806

@s-anes

Description

@s-anes

Enhancement

As a developer, when I clear out the schema and the form an empty form should be rendered.

Expected behaviour

The following renders a text box:

$scope.form= [
  "name"
];

$scope.schema={
"type": "object",
  "properties": {
    "name": {
      "title": "Name",
      "type": "string"
    }
  }
};

If I then want to change the schema and the form to:

$scope.form= [];

$scope.schema={
"type": "object",
  "properties": {
  }
};

I expected the text box to disappear and the page to be empty.

Actual behaviour

It actually keeps displaying the text box despite the schema and the form being empty.

I've using angular.copy in both the schema and form and then redraw as per comments in #395, #428 but no joy:

$scope.form = angular.copy(newForm);
$scope.schema.properties = angular.copy(newSchema.properties);
$scope.$broadcast('schemaFormRedraw');

If the schema isn't empty (has anything in properties), the form clears if empty. The problem is I want to have a schema and a form per panel, and if a panel is empty (no questions) the schema shouldn't have any properties.

Have I done something wrong or am I missing something? I'd appreciate if anyone could shed some light here.

Thanks!

@json-schema-form/angular-schema-form-lead

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions