Skip to content

Commit

Permalink
add IDs to inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
ajb committed Dec 19, 2013
1 parent 81d3ccf commit 5f94f88
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/models/formbuilder/response_field_address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def render_input(value, opts = {})
"""
<div class='input-line'>
<span class='street'>
<input type'text' name='response_fields[#{self[:id]}][street]' value='#{value['street']}' />
<input type'text' name='response_fields[#{self[:id]}][street]' id='response_fields_#{self[:id]}' value='#{value['street']}' />
<label>Address</label>
</span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/models/formbuilder/response_field_date.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def render_input(value, opts = {})
"""
<div class='input-line'>
<span class='month'>
<input type='text' name='response_fields[#{self[:id]}][month]' value='#{value['month']}' maxlength='2' />
<input type='text' name='response_fields[#{self[:id]}][month]' value='#{value['month']}' id='response_fields_#{self[:id]}' maxlength='2' />
<label>MM</label>
</span>
Expand Down
2 changes: 1 addition & 1 deletion app/models/formbuilder/response_field_dropdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def render_input(value, opts = {})
end

"""
<select name='response_fields[#{self[:id]}]'>
<select name='response_fields[#{self[:id]}]' id='response_fields_#{self[:id]}'>
#{options}
</select>
"""
Expand Down
11 changes: 9 additions & 2 deletions app/models/formbuilder/response_field_email.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ class ResponseFieldEmail < ResponseField
}

def render_input(value, opts = {})
tag(:input, type: 'text', name: "response_fields[#{self.id}]", class: "rf-size-#{self[:field_options]['size']}",
data: self.length_validations, value: value)
tag(
:input,
type: 'text',
name: "response_fields[#{self.id}]",
id: "response_fields_#{self[:id]}",
class: "rf-size-#{self[:field_options]['size']}",
data: self.length_validations,
value: value
)
end

def render_entry(value, opts = {})
Expand Down
2 changes: 1 addition & 1 deletion app/models/formbuilder/response_field_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def render_input(value, opts = {})

"""
<span class='existing-filename'>#{attachment.try(:upload).try(:file).try(:filename).try(:gsub, /\?.*$/, '')}</span>
<input type='file' name='response_fields[#{self[:id]}]' />
<input type='file' name='response_fields[#{self[:id]}]' id='response_fields_#{self[:id]}' />
"""
end

Expand Down
10 changes: 8 additions & 2 deletions app/models/formbuilder/response_field_number.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ class ResponseFieldNumber < ResponseField
}

def render_input(value, opts = {})
str = tag(:input, type: 'text', name: "response_fields[#{self.id}]",
class: "rf-size-#{self[:field_options]['size']}", value: value)
str = tag(
:input,
type: 'text',
name: "response_fields[#{self.id}]",
id: "response_fields_#{self.id}",
class: "rf-size-#{self[:field_options]['size']}",
value: value
)

if (units = self[:field_options]['units'].presence)
str += "<span class='units'>#{units}</span>".html_safe
Expand Down
9 changes: 7 additions & 2 deletions app/models/formbuilder/response_field_paragraph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ class ResponseFieldParagraph < ResponseField
}

def render_input(value, opts = {})
content_tag(:textarea, name: "response_fields[#{self.id}]", class: "rf-size-#{self[:field_options]['size']}",
data: self.length_validations) { value }
content_tag(
:textarea,
name: "response_fields[#{self.id}]",
id: "response_fields_#{self.id}",
class: "rf-size-#{self[:field_options]['size']}",
data: self.length_validations
) { value }
end

def render_entry(value, opts = {})
Expand Down
2 changes: 1 addition & 1 deletion app/models/formbuilder/response_field_price.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def render_input(value, opts = {})
<span class='above-line'>$</span>
<span class='dollars'>
<input type='text' name='response_fields[#{self[:id]}][dollars]' value='#{value['dollars']}' />
<input type='text' name='response_fields[#{self[:id]}][dollars]' id='response_fields_#{self[:id]}' value='#{value['dollars']}' />
<label>Dollars</label>
</span>
Expand Down
10 changes: 8 additions & 2 deletions app/models/formbuilder/response_field_text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ class ResponseFieldText < ResponseField
}

def render_input(value, opts = {})
tag(:input, type: 'text', name: "response_fields[#{self.id}]", class: "rf-size-#{self[:field_options]['size']}",
data: self.length_validations, value: value)
tag(
:input,
type: 'text',
name: "response_fields[#{self.id}]",
id: "response_fields_#{self.id}",
class: "rf-size-#{self[:field_options]['size']}",
data: self.length_validations, value: value
)
end

end
Expand Down
2 changes: 1 addition & 1 deletion app/models/formbuilder/response_field_time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def render_input(value, opts = {})
"""
<div class='input-line'>
<span class='hours'>
<input type='text' name='response_fields[#{self[:id]}][hours]' value='#{value['hours']}' maxlength='2' />
<input type='text' name='response_fields[#{self[:id]}][hours]' id='response_fields_#{self[:id]}' value='#{value['hours']}' maxlength='2' />
<label>HH</label>
</span>
Expand Down
11 changes: 9 additions & 2 deletions app/models/formbuilder/response_field_website.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ class ResponseFieldWebsite < ResponseField
}

def render_input(value, opts = {})
tag(:input, type: 'text', name: "response_fields[#{self.id}]", class: "rf-size-#{self[:field_options]['size']}",
value: value, placeholder: 'http://')
tag(
:input,
type: 'text',
name: "response_fields[#{self.id}]",
id: "response_fields_#{self.id}",
class: "rf-size-#{self[:field_options]['size']}",
value: value,
placeholder: 'http://'
)
end

def render_entry(value, opts = {})
Expand Down
2 changes: 1 addition & 1 deletion lib/formbuilder/form_renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def render_label
return unless @field.input_field

"""
<label for='response_fields[#{@field.id}]'>
<label for='response_fields_#{@field.id}'>
#{@field[:label]}
#{render_label_required if @field.required?}
</label>
Expand Down

0 comments on commit 5f94f88

Please sign in to comment.