On the client side, you can handle the UI changes using Javascript/Ajax. 
The problem is modeling the data in the DAL and the database. If there 
aren't too many distinct attributes across the types of items, you can use 
a single database table as usual, only populating the fields that are 
relevant for each given type. Another option might be a separate table for 
each type, again, if there is a relatively small fixed number of types. 
However, if there are a large number of types and/or attributes, and if you 
must be able to easily add more and more types/attributes over time 
(perhaps allowing users to do so directly), then you'll probably need a 
different modeling approach, such as the EAV 
model<http://en.wikipedia.org/wiki/Entity%E2%80%93attribute%E2%80%93value_model>.
 
web2py doesn't have any built-in facilities for defining and managing such 
a model, so you'd have to manually code the CRUD operations for such a 
model.

This kind of situation is actually better handled by a document-based 
datastore, such as MongoDB, which doesn't require a fixed schema for each 
document. The DAL does have an adapter for MongoDB, but it probably 
wouldn't be useful here because the DAL still expects a fixed schema. You 
would probably just have to use a native driver and queries with something 
like MongoDB.

Anthony

On Tuesday, April 16, 2013 7:34:40 PM UTC-4, Doug Girard wrote:
>
> I want to create a form which I can add multiple 'items' of different 
> 'types' that have different 'attributes'
>
> For example, lets use two types of food, pizza and steak
>
> You would start by selecting the type of food. Say pizza
>
> Upon selecting this type you would get more form fields, specific to the 
> type chosen. Maybe,
>
> dough:
> cheese:
> sauce:
> topping:
>
> Where if you had chosen steak, you would get a different set of 
> attributes. Maybe,
>
> cut:
> rarity:
>
> etc..
>
> I hope I've made myself clear, I'm just a beginner at python and am a bit 
> stuck. Thank You!
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to