Questions tagged [form-helpers]

Forms in web applications are an essential interface for user input. However, form markup can quickly become tedious to write and maintain because of the need to handle form control naming and its numerous attributes. Rails does away with this complexity by providing view helpers for generating form markup.

Forms in web applications are an essential interface for user input. However, form markup can quickly become tedious to write and maintain because of the need to handle form control naming and its numerous attributes. Rails does away with this complexity by providing view helpers for generating form markup.

338 questions
61
votes
3 answers

How to use Simple Ajax Beginform in Asp.net MVC 4?

I am new in Asp.net MVC and i researched about Ajax.BeginForm but when i apply codes it did not work. Can you share very simple example with Ajax.Beginform with View, Controller, Model? Thanks.
Soner
  • 1,280
  • 3
  • 16
  • 40
38
votes
11 answers

How to make a check_box checked in rails?

I made checkboxes using the following rails form helper: <%= check_box("tag", tag.id) %> However, I need to make some of them checked by default. The rails documentation doesn't specify how to do this. Is there a way? How?
36
votes
4 answers

How do I get the HTML 'name' attribute a rails form builder will generate for a certain field?

When you've got a form field such as this: <%= f.text_field :last_name %> it will generate this in HTML: I'd like to know if there's any way to get the name attribute…
digitalWestie
  • 2,647
  • 6
  • 28
  • 45
34
votes
3 answers

adding a class to a text_field_tag

I am trying to give a class to my text_field_tag I have this <%= text_field_tag :login_aei, class: 'form-control' %> but it keeps generating this : What…
David Geismar
  • 3,152
  • 6
  • 41
  • 80
30
votes
2 answers

rails erb form helper options_for_select :selected

I have an edit form in erb. <%= form_for @animal do |f| %> Within the code I have a select with options: <%= f.select :gender, options_for_select([['Mare'], ['Stallion'], ['Gelding']], :selected => :gender) %> However, the select is not showing…
Drew Harris
  • 486
  • 1
  • 5
  • 13
23
votes
8 answers

link_to delete url is not working

I have the following link_to delete url in my app <%=link_to "Delete",blog_path(@blog.id), :method => :delete, :class => "delete", :confirm => "Are you sure ?"%> It does not seem to be working.When I click this url, it just takes me to the show…
felix
  • 11,304
  • 13
  • 69
  • 95
22
votes
3 answers

check_box_tag with label_tag click action

<%= f.label :category %>
<%= check_box_tag 'category[]', '1', false %> <%= label_tag 'community', 'community', class: 'category_select', value: '1' %> <%= check_box_tag 'category[]', '2', false %> <%= label_tag 'food', 'food', class:…
Dudo
  • 4,002
  • 8
  • 32
  • 57
19
votes
7 answers

Use custom id for check_box_tag in Rails

How do you set a custom id when using a check_box_tag helper in rails? I have a loop which creates a bunch of checkboxes based on a collection: - subject.syllabus_references.each do |sr| = check_box_tag 'question[syllabus_reference]', sr.id,…
Ganesh Shankar
  • 4,826
  • 8
  • 43
  • 56
18
votes
2 answers

Custom HTML attribute requires a custom helper?

I'm trying to create a form with some custom data attributes on the inputs: This seemed like a nice clean way to have easy front-end access (haha!) with jquery:…
RSG
  • 7,013
  • 6
  • 36
  • 51
16
votes
3 answers

Rails simple_form checkboxes for serialized Array field

I am using SimpleForm to build my form. I have say the following model: class ScheduledContent < ActiveRecord::Base belongs_to :parent attr_accessible :lots, :of, :other, :fields serialize :schedule, Array end I want to construct a…
Joerg
  • 3,553
  • 4
  • 32
  • 41
15
votes
1 answer

Ruby/Rails - Properly Display/Format Text From The Text Area Form Control

I have a interesting problem. I have a :text field in my model with displays a large chunk of data, usually about three paragraphs. When I enter the text in on the new view it might look…
ChrisWesAllen
  • 4,935
  • 18
  • 58
  • 83
14
votes
3 answers

Rails 3 - Make text field accept only numeric values

How do I make a text field accept only numeric values? If I press a letter or a symbol, the text field should not be filled, it should only allow numbers. Is there a rails way to do this?
Angelo
  • 905
  • 1
  • 17
  • 35
12
votes
2 answers

Applying CSS class on time_zone_select

Is it possible to provide a CSS class for the time_zone_select FormHelper in Rails 3. I currently have something like f.time_zone_select :time_zone Have tried options like - f.time_zone_select :time_zone, nil, :class => 'classname' But that…
Sam Wilder
  • 869
  • 1
  • 9
  • 21
11
votes
1 answer

if a text_field_tag form helper in rails is disabled, does it not submit?

I have a text_field_tag in my form, i really want it just for display (all my jquery updates this text field), using a date picker. Though I don't want the user to type in here, so I said the :disabled => true and sure enough it is disabled, values…
Codejoy
  • 3,722
  • 13
  • 59
  • 99
10
votes
1 answer

collection_select method gives error in Rails 3.1.1

I have a Model called Category and other Model Product. They have has_many and belongs_to relation. But code in my view

<%= f.collection_select(:product, :category_id, Category.all, :id, :name)%> is giving me undefined method `merge' for…

Bhushan Lodha
  • 6,824
  • 7
  • 62
  • 100
1
2 3
22 23