form-helpers

How does rails decide to render a form with a method of PUT or POST?

ぐ巨炮叔叔 提交于 2019-12-18 12:34:44
问题 Rails generates a form partial that can be used on both the page rendered by a get action and a page rendered by a new action. If it is the former the form's method is set to PUT, if the latter the form's action is set to POST. How does rails decide which method to use? 回答1: if the object passed to the form is persisted?, the form builder knows that you are updating an object and will therefore render a PUT action. If it is not persisted, then it knows you are creating a new object and it

Cakephp Form Helper

喜欢而已 提交于 2019-12-13 16:44:36
问题 How can i achieve the following using cakephp form helper <input type="text" required> 回答1: $this->Form->input('foo', array('required' => 'required')); This will set the required attribute in longhand required="required" format, but will have the same effect. 来源: https://stackoverflow.com/questions/5428814/cakephp-form-helper

bootstrap form helper phone wont work

爱⌒轻易说出口 提交于 2019-12-11 14:16:47
问题 I m trying to make a website using form Bootstrap framework. As part of my code I have <div class="control-group"> <label class="control-label" for="inputTell">Telephone</label> <div class="controls"> <input type="text" id="inputTell" class="bfh-phone" data-format="(ddd) ddd-dddd"> </div> </div> This is the image: It shouldnt be like that. It shouldn't accept any strings and it should give me the phone format like this: I already have the necessary JS files in my directory but I am not sure

Ruby on Rails helper prints out odd stuff

安稳与你 提交于 2019-12-11 06:33:11
问题 I want to create a helper which iterates thru the list of user's communities and creates as many thumbnails as the number of comunities available. So I created these 2 helper methods def print_admined_group_thumbs @user_groups_hash[:admined_groups].each { |group_hash| name = group_hash[:name] group_id = group_hash[:group_id] photo = group_hash[:photo] members_count = group_hash[:members_count].to_i concat(get_group_thumbnail_html(group_id, name, members_count, photo)) } end # creates a small

adding size option to file_field tag in rails

元气小坏坏 提交于 2019-12-11 04:33:45
问题 ANSWERED I actually found the answer while formulating the question but I'm posting it any way since some might find this useful(as said here: https://meta.stackexchange.com/questions/49922/should-i-continue-adding-a-question-if-i-have-found-the-answer-myself) I'm having trouble adding size to a file field in ROR3. Here was my syntax: = f.file_field :file, :size => "11" this doesnt appear but creates an file input field with this: <input type="file" name="soap_test_zip_file[file]" id="soap

Why is an apostrophe appearing as ' in Ruby on Rails and is this a sign of a security issue?

牧云@^-^@ 提交于 2019-12-10 20:33:55
问题 I'm new to Ruby on Rails and I'm using a form_helper to create and update records. In the form below, I'm collecting information to save data for maps that users can create. The :name field is the name that user gives to a map. It's saved to a MySQL table into a field that is varchar(255). If I name a map "John's Map", it appears in both the database and in the view as John's Map How can I prevent this from happening, and is my code susceptible to SQL injection with this approach? I've seen

Custom HTML attribute requires a custom helper?

拈花ヽ惹草 提交于 2019-12-09 14:12:40
问题 I'm trying to create a form with some custom data attributes on the inputs: <input type="text" data-family="Dinosaurs"> This seemed like a nice clean way to have easy front-end access (haha!) with jquery: $("[data-family='Dinosaurs']").doSomething() The problem is I can't get Rails (3.0.3) to render the attribute. <%= f.text_field :question, :id=>"poll_question", :class=>"BigInput", :style=>"width:98%;", :attributes=>"data-submit_clear='1'" %> I've tried many permutations to no avail and can

Using two separate fields for the same parameter in a Rails form handler?

南楼画角 提交于 2019-12-08 04:25:20
问题 I'm new to Rails and am fixing a Rails 2 site. I have a form that lets the user add information for the starting location (:start) EITHER with an input OR with a dropdown field. However, I have found that when I include both options, only the dropdown (which comes last) submits data, while the input is ignored. What's the right way to include both options? MY VIEW <% form_for @newsavedmap, :html=>{:id=>'createaMap'} do |f| %> <%= f.error_messages %> <p>Enter a street address, city, and state:

Creating form for rails-setting

谁说胖子不能爱 提交于 2019-12-08 03:54:39
问题 In my Rails app, I'm using the gem rails-settings to save a user's email notification settings. I'm trying to create a form to update a user's notification settings. It should consist of a set of checkboxes where the user selects what they want to receive email notifications about. In the rails-setting README, there are no examples of how to integrate it with a form. The closest tutorial I found was listed in the issues: https://github.com/ledermann/rails-settings/issues/46 But I'm not sure

Creating form for rails-setting

不羁的心 提交于 2019-12-06 14:38:06
In my Rails app, I'm using the gem rails-settings to save a user's email notification settings. I'm trying to create a form to update a user's notification settings. It should consist of a set of checkboxes where the user selects what they want to receive email notifications about. In the rails-setting README, there are no examples of how to integrate it with a form. The closest tutorial I found was listed in the issues: https://github.com/ledermann/rails-settings/issues/46 But I'm not sure what the actual form element would look like in my view. For example, if I wanted to create an input