nested-forms

Asp.Net nested form

耗尽温柔 提交于 2019-12-06 06:59:55
问题 I need to supply an html form (not a server form) for searching within an asp.net web-forms website. The form will post to another website where an indexed search is performed. Seeing as nested forms don't work well in asp.net, what is the simplest approach for this? The nested form is a simple html form that performs a "get" against the search website, which I do not have programmatic control over. Update: I resolved my issue by simply moving the server form to the appropriate place on the

Rails nested form on many-to-many: how to prevent duplicates?

旧街凉风 提交于 2019-12-06 05:33:57
I've setup a nested form in my rails 3.2.3 app, it's working fine, my models are: class Recipe < ActiveRecord::Base attr_accessible :title, :description, :excerpt, :date, :ingredient_lines_attributes has_and_belongs_to_many :ingredient_lines accepts_nested_attributes_for :ingredient_lines end and: class IngredientLine < ActiveRecord::Base attr_accessible :ingredient_id, :measurement_unit_id, :quantity has_and_belongs_to_many :recipes belongs_to :measurement_unit belongs_to :ingredient end As above, a Recipe can have multiple IngredientLines and vice versa. What I'm trying to avoid is record

Rails 4: Multiple image upload using paperclip

ⅰ亾dé卋堺 提交于 2019-12-06 04:13:26
I'm looking to upload multiple images to my 'locations' model. I've called the images model 'assets'. One location has multiple assets. I'm also using paperclip to handle the uploads and nested_form to allow selecting multiple assets. Weirdly, the locations hash looks to be passing the variables correctly, but they don't appear to be being picked up by the assets model. Any help would be great! Location model class Location < ActiveRecord::Base has_many :location_post has_many :posts, :through => :location_post has_many :assets, dependent: :destroy attr_accessor :asset, :assets_attributes

Rails 4: Adding child_index to dynamically added (nested) form fields with Cocoon Gem

不问归期 提交于 2019-12-05 21:44:35
问题 UPDATED: I am trying to add/remove form fields to a nested form involving multiple models. I have seen the "Dynamic Forms" railscast by Ryan Bates and I have referred to this article using the Cocoon Gem. Following that article has made everything work perfectly except for the child_index. The child_index is present only on the first :kid input field ( :name ) and the first :pet input fields ( :name and :age ). Then it goes back to an authenticity token for the fields being added. I've

nested form & habtm

橙三吉。 提交于 2019-12-05 15:36:00
I am trying to save to a join table in a habtm relationship, but I am having problems. From my view, I pass in a group id with: <%= link_to "Create New User", new_user_url(:group => 1) %> # User model (user.rb) class User < ActiveRecord::Base has_and_belongs_to_many :user_groups accepts_nested_attributes_for :user_groups end # UserGroups model (user_groups.rb) class UserGroup < ActiveRecord::Base has_and_belongs_to_many :users end # users_controller.rb def new @user = User.new(:user_group_ids => params[:group]) end in the new user view, i have access to the User.user_groups object, however

Marking multi-level nested forms as “dirty” in Rails

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 09:34:41
I have a three-level multi-nested form in Rails. The setup is like this: Projects have many Milestones, and Milestones have many Notes. The goal is to have everything editable within the page with JavaScript, where we can add multiple new Milestones to a Project within the page, and add new Notes to new and existing Milestones. Everything works as expected, except that when I add new notes to an existing Milestone (new Milestones work fine when adding notes to them), the new notes won't save unless I edit any of the fields that actually belong to the Milestone to mark the form "dirty"/edited.

ASP .NET MVC 3 - How to submit an ajax form nested within an html form

 ̄綄美尐妖づ 提交于 2019-12-05 03:37:08
I have an ASP .NET MVC 3 project and a problem with one of my 'Create' views. I have cascading drop-down fields that I have implemented with ajax forms. The view is roughly speaking - like this: @using (Html.BeginForm(...)) { @Html.MyDropDown1 using (Ajax.BeginForm(...)) { @Ajax.MyDropdown2 <input type="submit" value="Select" /> } using (Ajax.BeginForm(...)) { @Ajax.MyDropdown3 <input type="submit" value="Select" /> } <!-- other form fields --> <input type="submit" value="Create" /> } The problem is that the submit buttons inside the ajax forms actually submit the outer html form. Is there any

HABTM relationships and accepts_nested_attributes_for

戏子无情 提交于 2019-12-05 01:10:12
问题 I have a form that lets me create new blog posts and I'd like to be able to create new categories from the same form. I have a habtm relationship between posts and categories, which is why I'm having trouble with this. I have the following 2 models: class Post < ActiveRecord::Base has_and_belongs_to_many :categories attr_accessible :title, :body, :category_ids accepts_nested_attributes_for :categories # should this be singular? end class Category < ActiveRecord::Base has_and_belongs_to_many

Deeply nested Rails forms using belong_to not working?

谁都会走 提交于 2019-12-04 23:02:01
问题 I'm working on a messy form which among other things has to manage a section with two-level nesting. It's almost working, but there's a snag and the only thing I can see that's different from other deeply-nested forms that work is that there's a belongs_to relationship rather than has_many. Here are the models: Event has_many :company_events, :dependent => :destroy accepts_nested_attributes_for :company_events CompanyEvent belongs_to :company accepts_nested_attributes_for :company, :update

Nested Model Forms - Railscast #196 revised - Adding fields via jQuery not working

放肆的年华 提交于 2019-12-04 13:42:30
I was following the Railscast #196 revised and everything went basically fine, but I am not able to add new fields to the nested form. The "remove fields" function works nicely, but after click on "link_to_add_fields", the browser jumps to the top of the page, and no new field appears. There are already a ton of questions to this railscast, like here or here , and I tried to read all of them, but most of them are referring to the original casts from 2010. I am stuck for hours now, and I can't figure out, where my problem is. Sorry, if its a rookie mistake, I am quite new to rails. Any help