angular-schema-form icon indicating copy to clipboard operation
angular-schema-form copied to clipboard

Add UI Policies

Open Anthropic opened this issue 7 years ago • 2 comments

Enhancement

As a user/developer, when I change a field value I should be able to make other fields become readonly, required, defaulted or hidden based on conditions that can be evaluated after certain change parameters are met.

This includes multiple fields to watch for change and the option to apply updates to multiple fields as well.

Related issues

#597

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

Anthropic avatar May 13 '17 05:05 Anthropic

There is a function to redraw the schema form.

// We also listen to the event schemaFormRedraw so you can manually trigger a change if.  
// part of the form or schema is chnaged without it being a new instance.
        scope.$on('schemaFormRedraw', function() {
          var schema = scope.schema;
          var form   = scope.initialForm ? angular.copy(scope.initialForm) : ['*'];
          if (schema) {
            render(schema, form);
          }
        });

You can check your model and edit your actual form instance then broadcast.


var model = myModel;
angular.forEach($scope.form, function (detail) {
              if(detail.key[0] == 'name' && model.changed){
                detail.readonly = true;
              }
            });
$scope.$broadcast('schemaFormRedraw');

This solve your problem?

camilobaezcamba avatar Nov 14 '17 14:11 camilobaezcamba

@camilobaezcamba this ticket is for planning a feature I plan to add to the framework in future and is more of a reminder for myself :)

Anthropic avatar Nov 14 '17 23:11 Anthropic