form-for

regex pattern with form for ruby on rails

大憨熊 提交于 2020-12-06 02:39:23
问题 is there support for pattern attribute when using form_for? <%= form_for order_form do |f| %> <%= f.label "name" %> <%= f.text_field :name, required: true %> <%= f.label "Number" %> <%= f.telephone_field :phone, pattern: "\\d{10}" %> <%= f.submit %> I'm trying to put together a regex pattern to ensure that phone numbers are in correct format. My problem is that the pattern attribute wont take regex only strings <%= f.telephone_field :phone, pattern: /\d{10}/ %> doesnt work so when i write the

regex pattern with form for ruby on rails

拥有回忆 提交于 2020-12-06 02:38:59
问题 is there support for pattern attribute when using form_for? <%= form_for order_form do |f| %> <%= f.label "name" %> <%= f.text_field :name, required: true %> <%= f.label "Number" %> <%= f.telephone_field :phone, pattern: "\\d{10}" %> <%= f.submit %> I'm trying to put together a regex pattern to ensure that phone numbers are in correct format. My problem is that the pattern attribute wont take regex only strings <%= f.telephone_field :phone, pattern: /\d{10}/ %> doesnt work so when i write the

Require old password to make new password

百般思念 提交于 2020-04-08 05:50:42
问题 Right now every time I change anything in user/edit the form requires the user to set a new password. I would like for it to require the current password (how can I ask for current password?) only incase a new password is entered. How can I achieve this, thanks a lot for this. <%= form_for(@user, :html => {:multipart => true}) do |f| %> <%= render 'shared/error_messages', object: f.object %> <%= f.text_field :name, placeholder: :name %> <%= f.text_field :email, placeholder: :email %> <%= f

Why would my form submit only one model's data?

白昼怎懂夜的黑 提交于 2020-01-22 03:43:06
问题 I have a form that is intended to submit two models, the first model has_one of the other model, Student_Detail . Many users on here have helped me with some errors that I encountered already, and now my form submits successfully, but only submits the primary model, Participant . I've submitted the form a few times and it stores all information that is a direct attribute of the Participant model. In active admin the Participant model data populates, but no Student_Detail records exist. In the

Rails form_for with file_field and remote => true and format => :js

做~自己de王妃 提交于 2020-01-21 12:22:09
问题 I am submitting a form_for with a file_field in it. When the form is submitted with a post, the controller responds with a .js file which will be executed. The file_field is optional. When I upload a file, the js file is opened in a new document (as a simple text file) and the js is not executed. When I don't upload any file, the response div is updated. I want the update success to be notified in the response div or a failure message independent of the file upload. May be this is done for

How to create a submit all button for my form_for

依然范特西╮ 提交于 2020-01-17 04:58:30
问题 I am new to Ruby on Rails. How can I make my form for submit all at the same time when I click the link_to "save" . Thank you for your answers. This is a snippet of my view file. I would like to save form for at the same time with one button. <% @sheets.each do |getsheets| %> <%= image_tag "sheets/#{getsheets.sheetimage.split('/')[-2]}/#{getsheets.sheetimage.split('/')[-1]}" %> <div> <%= form_for getsheets , :url => sheet_attachment_path(getsheets.sheetid,getsheets.sheetid) do |f| %> <%= f

Saving radio buttons values in rails

我只是一个虾纸丫 提交于 2020-01-07 04:32:26
问题 I'm trying to use radio buttons in my rails application. Currently the buttons are showing up on the page as expected, but the value is not being saved upon submission. I think the problem is actually with my submit button - nothing is happening when it is pressed. Here is the code for my page with the radio buttons: <div class="form_row> <%= form_for @term, :url=>{ :action =>"update_status" } do |f| %> <%= f.radio_button :status, 'on' %><b>On</b> <br/> <%= f.radio_button :status, 'off' %><b

HABTM Form not submitting more than one value in rails

别等时光非礼了梦想. 提交于 2020-01-06 04:06:28
问题 I am trying to assign a group of players to a fixture though a form. I have been trying to list all the players from my players table via checkboxes so the user can select which players he wants for the fixture. Models There are 3 models concedered with the fixtures and players class Fixture < ActiveRecord::Base belongs_to :team has_many :player_fixtures has_many :players, :through => :player_fixtures has_one :venue class Player < ActiveRecord::Base has_and_belongs_to_many :teams has_many

Submit button outside form_for loop

送分小仙女□ 提交于 2020-01-05 11:35:13
问题 I have set up some horizontal tabs using twitter bootstrap and I am rendering a form inside each of the tabs: <div class="tab-content"> <div id="tab1" class="tab-pane active"> <%= render :partial => "shipdr/websites/form", locals: {:@shipdr_website => shipdr_website} %> </div> <div id="tab2" class="tab-pane"> Another form (not yet implemented) </div> <div id="tab3" class="tab-pane"> Another form (not yet implemented). </div> </div> Then in shipdr/websites/form I have: <%= simple_form_for(

Rails 3.0.10, customer routes, post and form_for tag

孤街浪徒 提交于 2020-01-04 06:01:37
问题 I have this in my routes: resources :events do collection do post 'moderate' end end Rake routes tells me: moderate_events POST /events/moderate(.:format) {:controller=>"events", :action=>"moderate"} I have an "administration" controller that simply lists Events that need moderating: @modevents = Event.where('moderated <> 1') So far so good, all the events that haven't been moderated can be displayed in the view: <%- @modevents.each do |me| -%> Display Stuff here <%- end -%> I want to put a