Skip to content

Instantly share code, notes, and snippets.

@nfriend21
Created March 19, 2013 16:01
Show Gist options
  • Save nfriend21/5197346 to your computer and use it in GitHub Desktop.
Save nfriend21/5197346 to your computer and use it in GitHub Desktop.
field_type = params[:form_field][:field_type]
case field_type
when 'text'
@form_field.code = %Q{<input type="text" name="#{@form_field.id}-text-field" class="text-input">}
when 'radio'
@field_option.code = %Q{<input type="radio" name="form_field_#{@form_field.id}-radio_field_#{@field_option.id}" class="radio-option-label">}
@field_option.save
when 'checkbox'
@field_option.code = %Q{<input type="checkbox" name="form_field_#{@form_field.id}-checkbox_field_#{@field_option.id}" class="checkbox-option-label">}
@field_option.save
when 'dropdown'
@form_field.code = %Q{<select name="form_field_#{@form_field.id}" class="dropdown-option-label">}
@form_field.code_end = %Q{</select>}
@field_option.code = %Q{<option name="form_field_#{@form_field.id}-radio_field_#{@field_option.id}" class="dropdown-option-label">}
@field_option.code_end = %Q{</option>}
@field_option.save
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment