Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
  <head>
    <!-- Twitter bootstrap -->
    <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.css" rel="stylesheet">
    <!-- apiCheck is used by formly to validate its api -->
    <script src="//rawgit.com/kentcdodds/api-check/master/dist/api-check.js"></script>
    <!-- This is the latest version of angular (at the time this template was created) -->
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.js"></script>
    
    <!-- This is the current state of master for formly core. -->
    <script src="//rawgit.com/formly-js/angular-formly/master/dist/formly.js"></script>
    <!-- This is the current state of master for the bootstrap templates -->
    <script src="//rawgit.com/formly-js/angular-formly-templates-bootstrap/master/dist/angular-formly-templates-bootstrap.js"></script>
    <!-- additional dependencies go here -->
    
    <title>Angular Formly Question</title>
  </head>
  <body ng-app="formlyQuestion" ng-controller="MainCtrl as vm">
    <div>
      <h1>
        angular-formly: multiCheckbox defaults to required
        <a ng-if="vm.issueNumber" ng-href="{{vm.issueLink}}">{{vm.issueNumber}}</a>
      </h1>
      <small>
        angular: {{vm.env.angularVersion}} |
        angular-formly: {{vm.env.formlyVersion}}
      </small>
      <hr />
      <div>
        <h2>Steps to Reproduce</h2>
        <ol>
          <li>step 1 : check any one of the multiCheckbox</li> 
          <li>step 2 : uncheck the one checked previously</li>
          <li>Notice the field became invalid because require is set to true</li>
        </ol>
      </div>
      <hr />
      <div>
        <h2>Form</h2>
        <form ng-submit="vm.onSubmit()" name="vm.form" novalidate>
          <formly-form model="vm.model" fields="vm.fields" options="vm.options" form="vm.form">
            <button type="submit" class="btn btn-primary submit-button" ng-disabled="vm.form.$invalid">Submit</button>
            <button type="button" class="btn btn-default" ng-click="vm.options.resetModel()">Reset</button>
          </formly-form>
        </form>
      </div>
      <hr />
      <div>
        <h2>Model Value</h2>
        <pre>{{vm.model | json}}</pre>
      </div>
      
      <hr />
      
      <div>
        <h2>Form</h2>
        <pre>{{vm.form | json}}</pre>
      </div>
      
      <hr />
      <div>
        <h2>Fields <small>(note, functions are not shown)</small></h2>
        <pre>{{vm.originalFields | json}}</pre>
      </div>
      
      <hr />
      
      <div>
        <h2>Form State</h2>
        <pre>{{vm.options.formState | json}}</pre>
      </div>
    </div>
    <!-- Put custom templates here -->
  </body>
</html>
 
body {
  margin: 20px
}
.formly-field {
  margin-bottom: 16px;
}
 
/* global angular */
(function() {
  'use strict';
  console.clear(); // <-- keep the console clean in jsbin
  var app = angular.module('formlyQuestion', [
    // additional dependencies go here
    'formly',
    'formlyBootstrap'
  ]);
  app.run(function(formlyConfig) {
    // set types here
  });
  app.controller('MainCtrl', function MainCtrl(formlyVersion) {
    var vm = this;
    // funcation assignment
    vm.onSubmit = onSubmit;
    // variable assignment
    vm.issueNumber = ''; // <-- fill this in;
    vm.env = getEnv();
    vm.model = {};
    vm.options = {formState: {}};
    vm.fields = getFields();
    vm.originalFields = angular.copy(vm.fields);
    
    vm.issueLink = 'https://github.com/formly-js/angular-formly/issues/' + vm.issueNumber;
    // function definition
    function getFields() {
      // return your fields here
      return [
    {
      key: 'text',
      type: 'input',
      templateOptions: {
        label: 'Text',
        placeholder: 'Formly is terrific!'
      }
    },
    {
      type: 'multiCheckbox',
      key:'type_listid',
      templateOptions: {
          label: 'Type multiCheckbox',
          description: 'Select one or more type',
          options: [{"name":"Study","value":"1"},{"name":"Research","value":"2"},{"name":"Travel","value":"3"}],
      }
    }
  ];
    }
    function onSubmit() {
      vm.options.updateInitialValue();
      alert(JSON.stringify(vm.model), null, 2);
    }
    function getEnv() {
      return {
        angularVersion: angular.version.full,
        formlyVersion: formlyVersion
      };
    }
  });
})();
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
qinchepro
0viewers