lib/formalizer/form_field.rb
# generates a text id to use inside forms
# strips non alpfanumeric characters from name, lowercases the result
# and replaces whitespaces with '_'
# adds a unique hash at the end
# e.g. 'First Name (required)' -> 'first_name_required_f5f6f0ae0717937a039488c5b6163d6f'
generates a text id to use inside forms
strips non alpfanumeric characters from name, lowercases the result
and replaces whitespaces with '_'
adds a unique hash at the end
e.g.
generates a text id to use inside forms strips non alpfanumeric characters from name lowercases the result and replaces whitespaces with ' _ ' adds a unique hash at the end e . g .
def generate_id
      base_name = @localized[:name][:en] || @localized[:name].values.first || ''
      underscored_name = base_name.gsub(/[^0-9a-z ]/i, '').downcase.gsub(/\s+/, '_') << '_'
      underscored_name += Digest::MD5.new.update(Time.now.to_i.to_s).hexdigest
    end
def generate_id base_name = @localized [ :name ] [ :en ] || @localized [ :name ] . values . first || '' underscored_name = base_name . gsub ( / [^0-9a-z ] /i , '' ) . downcase . gsub ( / \s + / , '_' ) << '_' underscored_name += Digest :: MD5 . new . update ( Time . now . to_i . to_s ) . hexdigest end
generates a text id to use inside forms
strips non alpfanumeric characters from name, lowercases the result
and replaces whitespaces with '_'
adds a unique hash at the end
e.g.
generates a text id to use inside forms strips non alpfanumeric characters from name lowercases the result and replaces whitespaces with ' _ ' adds a unique hash at the end e . g .