 ST.class 'EnumFieldView', 'View', ->
   @initializer 'withValuesNull', (values, _null) ->
     @init()
-    @_value = null
+    @_value = if _null then null else values[0][1]
     @_null = _null
     @_values = values
     @_valueIndex = {}

        @_skipUpdate = true
        @value newValue
  
  @method '_valueChanged', (oldValue, newValue) ->
    if @_skipUpdate
      @_skipUpdate = false
    else if @_loaded
      @_selectElement[0].selectedIndex = if @_valueIndex[newValue]? then @_valueIndex[newValue] else 0
  
  @method '_valuesChanged', (oldValues, newValues) ->
    @value null unless @_values[@_value]
    @renderOptions() if @_loaded
  
  @method '_idChanged', (oldValue, newValue) ->

  @property 'values'
  @property 'selectElement'
  @property 'id'
  
  @method 'isValueValid', (value) ->
    if value is null
      @_null
    else
      for option in @_values
        return true if option[1] == value
      false
  
  @method 'render', ->
    @_selectElement = $ '<select />'
