Sha256: e74fe86e008b2f7aeccb3636ec7b17184fb4621003b0094ecc75898d8e6dc1f7
Contents?: true
Size: 632 Bytes
Versions: 2
Compression:
Stored size: 632 Bytes
Contents
module Forms class GroupForm < Kadmin::Form delegate_attributes :name, :owner_id def initialize(*args) super raise(ArgumentError, 'Model given should be a group') unless @model.is_a?(Group) end def owner owner = @model.owner || Person.new return Forms::PersonForm.new(owner) end def owner_attributes=(attributes) form = owner form.assign_attributes(attributes) end def model_valid? super if @model&.owner&.changed? && !@model.owner.valid? @errors.add(:base, :invalid, message: 'owner has invalid attributes') end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
kadmin-0.1.7 | test/dummy/lib/forms/group_form.rb |
kadmin-0.1.6 | test/dummy/lib/forms/group_form.rb |