How to use the ember-form-builder/components/inputs/collection-input.extend function in ember-form-builder

To help you get started, we’ve selected a few ember-form-builder examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nibynic / ember-form-builder / addon / components / inputs / checkboxes-input.js View on Github external
import { computed } from '@ember/object';
import CollectionInput from 'ember-form-builder/components/inputs/collection-input';
import byDefault from 'ember-form-builder/utilities/by-default';

export default CollectionInput.extend({
  tagName: 'div',
  optionComponentName: 'inputs/checkbox-option',

  change() {
    var indices = [];
    this.element.querySelectorAll('input').forEach(function(input, i) {
      if(input.checked) {
        indices.push(i);
      }
    });
    this._setSelection(indices);
  },

  inputType: computed('multiple', function() {
    return this.get('multiple') ? 'checkbox' : 'radio';
  }),