Skip to content

Select boxes with underscores in the value are set to blank on form load #925

cknoxrun opened this Issue Mar 6, 2013 · 1 comment

1 participant

cknoxrun commented Mar 6, 2013

I am using ActiveAdmin which uses Formtastic as it's form plugin. I have a field in my database (units). The possible values for units includes "umol/mmol_creatinine". If this unit is set in the database from a dropdown field, the unit is set in the database correctly. This is for nested attributes.

However, when the form reloads, the unit is now set to blank. The ActiveRecord attribute for units isn't picked up as having the value "umol/mmol_creatinine". So when the form is re-submitted, the value is set to blank for the units.

Here is my model:

class Metabolite < ActiveRecord::Base
   has_many :concentrations, :dependent => :destroy, :conditions => { :export_hmdb => 'Yes' }
   accepts_nested_attributes_for :concentrations, :allow_destroy => true

Here is the form element for units:

concentration_f.input :units, :collection => Concentration.units

Concentration.units is returning an array of possible units (taken directly from the database).

So far this only happens with values containing an underscore. I am going to try with other characters.

cknoxrun commented Mar 6, 2013

Nevermind, problem was not related to formtastic.

@cknoxrun cknoxrun closed this Mar 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.