On Mon, Dec 6, 2010 at 9:16 AM, Javier Garcia <tirengar...@gmail.com> wrote:

> Hi,
>
> i have this schema:
>
>  shop_products:
>    _attributes: { phpName: ShopProduct }
>    products_id: { phpName: Id, type: INTEGER, size: '11', primaryKey:
> true, autoIncrement: true, required: true }
>    products_quantity: { phpName: Quantity, type: INTEGER, size: '4',
> required: true }
>    products_model: { phpName: Model, type: VARCHAR, size: '12',
> required: false }
>    products_image: { phpName: Image, type: VARCHAR, size: '64',
> required: false }
>    products_price: { phpName: Price, type: DECIMAL, size: '15',
> scale: '4', required: false, defaultValue: '0.0000' }
>    products_date_added: { phpName: DateAdded, type: TIMESTAMP,
> required: true }
>    products_last_modified: { phpName: LastModified, type: TIMESTAMP,
> required: false }
>    products_date_available: { phpName: DateAvailable, type:
> TIMESTAMP, required: false }
>    products_weight: { phpName: Weight, type: DECIMAL, size: '5',
> scale: '2', required: true }
>    products_carati: { phpName: Carati, type: FLOAT, required: false,
> defaultValue: '1' }
>    products_status: { phpName: Status, type: TINYINT, size: '1',
> required: true }
>    manufacturers_id: { phpName: ManufacturerId, type: INTEGER, size:
> '11', required: false, foreignTable: shop_manufacturers,
> foreignReference: manufacturers_id, onDelete: SETNULL }
>    products_ordered: { phpName: Ordered, type: INTEGER, size: '11',
> required: true, defaultValue: '0' }
>
>
>  shop_categories:
>    _attributes: { phpName: ShopCategory }
>    categories_id: { phpName: Id, type: INTEGER, size: '11',
> primaryKey: true, autoIncrement: true, required: true }
>    categories_image: { phpName: Image, type: VARCHAR, size: '64',
> required: false }
>    parent_id: { phpName: ParentId, type: INTEGER, size: '11',
> required: true, defaultValue: '0', foreignTable: shop_categories,
> foreignReference: categories_id, onDelete: CASCADE, onUpdate:
> CASCADE }
>    sort_order: { phpName: SortOrder, type: INTEGER, size: '3',
> required: false }
>    date_added: { phpName: DateAdded, type: TIMESTAMP, required:
> false }
>    last_modified: { phpName: LastModified, type: TIMESTAMP, required:
> false }
>
>
I'm not sure if the foreign table name is the correct. You are refering to
the same table instead of shop_categories_description.
Again, I haven't worked in symfony's database models in a while :p


>  shop_categories_description:
>    _attributes: { phpName: ShopCategoryDescription }
>    categories_id: { phpName: CategoryId, type: INTEGER, size: '11',
> primaryKey: true, required: true, defaultValue: '0', foreignTable:
> shop_categories, foreignReference: categories_id, onDelete: CASCADE,
> onUpdate: CASCADE }
>    language_id: { phpName: LanguageId, type: INTEGER, size: '11',
> primaryKey: true, required: true, defaultValue: '1', foreignTable:
> culture, foreignReference: id, onDelete: CASCADE, onUpdate: CASCADE }
>    categories_name: { phpName: Name, type: VARCHAR, size: '32',
> required: true }
>
>
If one shop_category has only one description then you should have all that
in one table.



> Then, I have created an admin module from the ShopProducts model, but
> when i try to go to it it says:
>
> Class "ShopCategory" must implement a "__toString" method to be
> rendered in a "sfWidgetFormPropelChoice" widget
>
> As you can see, the model where the names of the categories are, is
> ShopCategoriesDescription. So, how could i get the name of the
> categories from the ShopCategory model class?
>
> Javier
>
> sf 1.4/propel
>

Look in the documentation how to create a toString function for
shop_category. In there you should point to something like this:

# Note that "$this" is the current shop_category

$this->getShop_categories_description->getCategories_name();

I'm not sure about the syntax. It could not use "_" but use the uppercase of
the first letter of a word.

Regards,
-- 
Diego Bello CarreƱo

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to