Hobo / hobo

The web app builder for Rails (moved from tablatom/hobo)
http://hobocentral.net
103 stars 39 forks source link

Making <select-many> polymorphic #136

Open stevemadere opened 9 years ago

stevemadere commented 9 years ago

Since <select-one> and<select-many> are used in auto-generated inline forms, it would probably be best to make them polymorphic so that the user has the option to customize the type of input used in an inline form.

Example scenario:


Imagine we have a model called Category, one called Product, one called Vendor.

class Category
  ...
  has_many :product_categories
  ...
end

class ProductCategory
  ...
  belongs_to :product
  belongs_to :category
  ...
end

class Product 
  ...
  belongs_to: vendor
  has_many :product_categories
  has_many :categories through: :product_categories, accessible:true
  ...
end

class Vendor
  ...
  has_many :products
  ...
end

The default edit/create form for Vendor includes an in-line creation
subform to add a Product to products and that subform *always* has
a <select-many> for the categories field but I want it to have a <check-many>.

As far as I can tell, the subform for adding to products while editing a Vendor
*does not employ any identifiable dryml tag for the Product subform*.

Because of that,  I cannot customize the choice of the editor tag used 
for categories in the Product subform.

My hope is to change the definition of <select-many>
(polymorphically  just for Category) so that it
actually invokes <check-many>.

e.g.
<def tag="select-many" for="Category>
  <check-many options="&Category.all">
</def>

A similar scenario arises with select-one when the relationships is _belongsto

iox commented 9 years ago

Great issue report, thank you.