formly-js / angular-formly

JavaScript powered forms for AngularJS
http://docs.angular-formly.com
MIT License
2.23k stars 405 forks source link

Ussing expressionProperties to change 'valid' or 'invalid' of other field #659

Open estvmachine opened 8 years ago

estvmachine commented 8 years ago

I want to change the value of 'invalid' of a field ussing expressionProperties. This can be made?. I got something like this:

 var date1={
          id:'DATE1',
          key: 'DATE1',
          type: 'datepicker',
          templateOptions: {
            label: 'Date 1',
            type: 'text',
            required: true,
          }
        };

        var date2={
          id:'DATE2',
          key: 'DATE2',
          type: 'datepicker',
          templateOptions: {
            label: 'Date 2',
            type: 'text',
            required: true,
            datepickerOptions:{
              initDate: new Date()
            }
          },
          expressionProperties:{
            'templateOptions.invalid' : function($viewValue, $formValue, scope){
                if(scope.model.DATE1 < scope.model.DATE2){
                  return true;
                }
                else 
                   return false;
            }
          }
        };
gillchristian commented 8 years ago

It should be possible yes!

Please post questions to StackOverflow using the angular-formly tag. Also you can ask on the gitter channel.

Try to keep issues for reporting bugs, requesting features or maybe discuss possible pull requests.