'use strict';

var d           = require('d')
  , include     = require('dom-ext/element/#/include')
  , exclude     = require('dom-ext/element/#/exclude')
  , DOMInput    = require('./_observable')
  , getFields   = require('./_get-fields')

  , Input;

module.exports = Input = function (document, ns/*, options*/) {
	DOMInput.apply(this, arguments);
};

Input.prototype = Object.create(DOMInput.prototype, {
	_render: d(function (options) {
		var el = this.make, desc = options.dbOptions
		  , data = getFields(options.observable.object, desc,
				{ selectField: desc.database.StringLine,
					otherField: desc.database.String })
		  , selectInput, other, label;

		this.addItem(selectInput =
			data.observables[data.names.selectField].toDOMInput(this.document,
				this.getOptions(data.observables[data.names.selectField])), 'select');
		this.addItem(other =
			data.observables[data.names.otherField].toDOMInput(this.document,
				this.getOptions(data.observables[data.names.otherField])), 'other');

		selectInput.on('change', function () {
			((selectInput.value === 'other') ? include : exclude).call(label);
		});

		this.dom = el('div', selectInput, label = el('label',
			data.observables[data.names.otherField].label, other));
	})
});

@@ -657,18 +657,87 @@
 r, label
+, observable;%0A%0A%09%09observable = data.observables%5Bdata.names.selectField%5D
 ;
-%0A
 %0A%09%09this.
@@ -840,32 +840,79 @@
 this.getOptions(
+observable)), observable.dbId);%0A%09%09observable = 
 data.observables
@@ -927,33 +927,19 @@
 mes.
-selectField%5D)), 'select')
+otherField%5D
 ;%0A%09%09
@@ -1091,23 +1091,31 @@
 eld%5D)), 
-'other'
+observable.dbId
 );%0A%0A%09%09se

Fix names in data set