I'm creating a tool to manage recipes and I'm stuck creating the recipe entry form. Each recipe has a many-to-many database relation with ingredients. The user needs to be able to enter an arbitrary number of ingredients for each recipe. Each ingredient used in a recipe must include the quantity and unit of the ingredient.
I've tried a couple of very kludgy and ineffective ways to make this work using FORM and JavaScript, but I can't get things working. How could I do this? === db.define_table("recipes", Field("name", notnull=True, requires=IS_NOT_EMPTY()), Field("description", "text", notnull=True), Field("servings", "integer") ) db.define_table("ingredients", Field("name", notnull=True, unique=True, requires=IS_NOT_EMPTY()), ) db.define_table("units", Field("name", notnull=True, unique=True, requires=IS_NOT_EMPTY()) ) db.define_table("recipes_ingredients", Field("recipe_id", "reference recipes", notnull=True, requires=IS_IN_DB(db, "recipes.id", "%(name)s")), Field("ingredient_id", "reference ingredients", notnull=True, requires=IS_IN_DB(db, "ingredients.id", "%(name)s")), Field("ingredient_num", "integer", notnull=True, requires=IS_NOT_EMPTY()), Field("quantity", "double", notnull=True, requires=[IS_NOT_EMPTY(), IS_MATCH("^\d+(/\d+)?$")]), Field("unit", "reference units", requires=IS_IN_DB(db, "units.id", "%(name)s")) )