multi-model-forms

AJAX update of accepts_nested_attributes_for partials

落爺英雄遲暮 提交于 2020-02-15 22:46:27
问题 My current working environment is Rails 2.3.8 (various reasons why my company hasn't moved to Rails 3). I'm trying to update elements of a multi-model form via AJAX calls - the idea being to replace certain dropdowns depending on how the user selects or fills in other fields. I have previously managed to get this working by using non-form based partials - the problem I have now is to reproduce the AJAX updating of the select dropdowns when the partials are based around form_for and fields_for

AJAX update of accepts_nested_attributes_for partials

不羁的心 提交于 2020-02-15 22:43:39
问题 My current working environment is Rails 2.3.8 (various reasons why my company hasn't moved to Rails 3). I'm trying to update elements of a multi-model form via AJAX calls - the idea being to replace certain dropdowns depending on how the user selects or fills in other fields. I have previously managed to get this working by using non-form based partials - the problem I have now is to reproduce the AJAX updating of the select dropdowns when the partials are based around form_for and fields_for

create new object in rails3 using multimodel form

时光怂恿深爱的人放手 提交于 2020-01-06 19:37:12
问题 I am n00b as rails is concerned. I am trying yo create a single multimodel form in my first rails3 project. Details are given below: class Item < ActiveRecord::Base # attr_accessible :title, :body has_many :item_reviews, :dependent => :destroy accepts_nested_attributes_for :item_reviews end and class ItemReview < ActiveRecord::Base # attr_accessible :title, :body belongs_to :item end So as clear, an item can have multiple reviews but when I am creating an item, I want at least 1 review for it

Django - change min_length in form __init__?

Deadly 提交于 2019-12-06 07:22:37
问题 Is there any way, to change the field's *min_length* argument inside form constructor? That doesn't work: def __init__(self, *args, **kwargs): super(CreateTeamForm, self).__init__(*args, **kwargs) self.fields['primary_color'].min_length = 4 回答1: Try setting the field's validators attribute in the __init__ method. from django.core.validators import MinLengthValidator class MyForm(forms.Form): primary_color = forms.CharField() def __init__(self, *args, **kwargs): super(MyForm, self).__init__(

Django - change min_length in form __init__?

笑着哭i 提交于 2019-12-04 13:13:16
Is there any way, to change the field's *min_length* argument inside form constructor? That doesn't work: def __init__(self, *args, **kwargs): super(CreateTeamForm, self).__init__(*args, **kwargs) self.fields['primary_color'].min_length = 4 Try setting the field's validators attribute in the __init__ method. from django.core.validators import MinLengthValidator class MyForm(forms.Form): primary_color = forms.CharField() def __init__(self, *args, **kwargs): super(MyForm, self).__init__(*args, **kwargs) # get all the validators on the field which are not MinLengthValidator validators = [v for v

AJAX update of accepts_nested_attributes_for partials

删除回忆录丶 提交于 2019-12-02 05:45:59
My current working environment is Rails 2.3.8 (various reasons why my company hasn't moved to Rails 3). I'm trying to update elements of a multi-model form via AJAX calls - the idea being to replace certain dropdowns depending on how the user selects or fills in other fields. I have previously managed to get this working by using non-form based partials - the problem I have now is to reproduce the AJAX updating of the select dropdowns when the partials are based around form_for and fields_for. Sorry for the following wall of text - i've tried to cut it down as much as possible (the code itself