forms

Ruby on Rails - Simple Form autocomplete association search

和自甴很熟 提交于 2021-01-27 07:35:40
问题 I've a form in a basic task management app which allows Tasks to be assigned to Users (task belongs_to user). I'm using Simple Form for this. Currently, the association is populated in the typical manner, with a dropdown list of users as such: <%= f.association :user, label_method: :name, value_method: :id, include_blank: false %> . However, as the number of Users grows, I'm looking to change this to an autocomplete form field to find users. I've tried following the Railscast on the subject,

Ruby on Rails - Simple Form autocomplete association search

核能气质少年 提交于 2021-01-27 07:33:02
问题 I've a form in a basic task management app which allows Tasks to be assigned to Users (task belongs_to user). I'm using Simple Form for this. Currently, the association is populated in the typical manner, with a dropdown list of users as such: <%= f.association :user, label_method: :name, value_method: :id, include_blank: false %> . However, as the number of Users grows, I'm looking to change this to an autocomplete form field to find users. I've tried following the Railscast on the subject,

Send Django Form as JSON via AJAX

為{幸葍}努か 提交于 2021-01-27 06:53:39
问题 I am working on project in Django 1.8.8 and I need to convert a django form into a JSON format so I can send it to the browser via an AJAX call. I found this package ( https://github.com/WiserTogether/django-remote-forms ) which is no more available on Pypi. Beside it's 2 years old since the last commit. Would you please give me some advice on what to do or which package to use ? Thank you in advance for your help. 回答1: The two main things you could do are: Render the form to an HTML string,

Keep form files after validation error

只愿长相守 提交于 2021-01-27 06:53:28
问题 I have a form where I simultaneously send several (let's say 10) files to the backend, along with some other regular input fields. When I find a validation problem in the backend I display the form again and fill the regular inputs (dropdowns, text inputs, etc.), but I cannot fill the file fields, forcing the user to select the files from the file directory again. The solution I think of is sending the base64 encoded representation of the files, and put them back in the form in case there is

radio button value being sent as “on” upon form submission

左心房为你撑大大i 提交于 2021-01-27 06:24:26
问题 I have a form with three radio button options. I need to submit the form data to another file, but for some reason the data sent contains the value of the selected radio button as "on" as opposed to the value of the value attribute. I tried manually manipulating and sending the data via the post() function but since I need to redirect the page upon submission, that results in a POST request followed by a GET request. The actual purpose of this code requires me to send this data to a function

Rails is adding a </form> tag in a spot that is not where I closed the do block, it is breaking my form

落爺英雄遲暮 提交于 2021-01-27 04:57:11
问题 I'm having one heck of an issue working out how to do this. I have 2 forms that need to be displayed next to each other but you can't embed forms, I got around this by just putting the 2nd form after the first one. However, rails is ignoring my <% end %> tag for the 2nd form and it is auto-closing the 2nd form before it needs to be closed. This is making my form not work. Here's the view with some bits omitted for brevity. <div class="row"> <div class="col-md-3"> <div class="well"> <%= render

Rails is adding a </form> tag in a spot that is not where I closed the do block, it is breaking my form

橙三吉。 提交于 2021-01-27 04:57:07
问题 I'm having one heck of an issue working out how to do this. I have 2 forms that need to be displayed next to each other but you can't embed forms, I got around this by just putting the 2nd form after the first one. However, rails is ignoring my <% end %> tag for the 2nd form and it is auto-closing the 2nd form before it needs to be closed. This is making my form not work. Here's the view with some bits omitted for brevity. <div class="row"> <div class="col-md-3"> <div class="well"> <%= render

Validating paginated forms in Angular JS (1.x)

感情迁移 提交于 2021-01-27 04:47:44
问题 I have a form in angular using tables with input field. Users can add and delete rows. Each cell can be of input type text,number date etc. If the table is too big the form becomes slow. One way to solve this is to paginate the table. Unfortunately paginating the table is a problem because I have custom validations on the input fields and the form should not submit if any of the fields in any page are not valid. For e.g. The user may fill the first page and submits the form without filling

Single label for two inputs

▼魔方 西西 提交于 2021-01-26 06:02:08
问题 I'm currently adding some date input to a form. I have a 'Start Date' and 'End Date' input but only want to use a single label ('Dates') for both inputs. Is it possible to do this? What are the accessibility concerns? My current thinking is to have a label 'Dates' that is shown then have two hidden labels for each input for screen readers etc. Is this the way to go? Are there any examples of large websites doing this kind of thing (Government websites if possible)? This is a project that may

Single label for two inputs

泪湿孤枕 提交于 2021-01-26 06:01:23
问题 I'm currently adding some date input to a form. I have a 'Start Date' and 'End Date' input but only want to use a single label ('Dates') for both inputs. Is it possible to do this? What are the accessibility concerns? My current thinking is to have a label 'Dates' that is shown then have two hidden labels for each input for screen readers etc. Is this the way to go? Are there any examples of large websites doing this kind of thing (Government websites if possible)? This is a project that may