Мені потрібно змінити форму докторської форми генератора адміністратора, яка входить до складу:
$this->embedRelation('MyRelation');
Макет за умовчанням виглядає так:

Мета - кожен елемент вибору повинен відображатися як текст в окремому рядку плюс ціна та кількість:

схема.имл
Game:
actAs:
Timestampable: ~
columns:
id: { type: integer(4), primary: true, autoincrement: true, unsigned: true }
game_name: { type: string(100), notnull: true }
indexes:
it:
fields: game_name
type: unique
Campaign:
actAs:
Timestampable: ~
columns:
id: { type: integer(4), primary: true, autoincrement: true, unsigned: true }
name: { type: string(100), notnull: true }
is_active: { type: boolean, notnull: true, default: 0 }
start: { type: datetime, notnull: true }
end: { type: datetime, notnull: true }
relations:
CampaignMatrix: { onDelete: CASCADE, local: id, foreign: campaign_id, foreignAlias: CampaignMatrixCampaign }
CampaignGames:
actAs:
Timestampable: ~
columns:
id: { type: integer(4), primary: true, autoincrement: true, unsigned: true }
campaign_id: { type: integer(4), notnull: true, unsigned: true }
game_id: { type: integer(4), notnull: true, unsigned: true }
indexes:
tc:
fields: [campaign_id, game_id]
type: unique
relations:
Campaign: { onDelete: CASCADE, local: campaign_id, foreign: id, foreignAlias: CampaignCampaignGames }
Game: { onDelete: CASCADE, local: game_id, foreign: id, foreignAlias: GameCampaignGames }
CampaignMatrix:
actAs:
Timestampable: ~
columns:
id: { type: integer(4), primary: true, autoincrement: true, unsigned: true }
item_id: { type: integer(4), notnull: true, unsigned: true }
campaign_id: { type: integer(4), notnull: true, unsigned: true }
price_id: { type: integer(4), notnull: true, unsigned: true }
quantity: { type: integer(4), notnull: true, unsigned: true }
relations:
Item: { onDelete: CASCADE, local: item_id, foreign: id, foreignAlias: ItemCampaignMatrix }
Campaign: { onDelete: CASCADE, local: campaign_id, foreign: id, foreignAlias: CampaignCampaignMatrix }
Price: { onDelete: CASCADE, local: price_id, foreign: id, foreignAlias: PriceItems }
Price:
columns:
id: { type: integer(4), unsigned: true }
currency_code: { type: string(3), notnull: true }
price: { type: float, notnull: true }
indexes:
tc:
fields: [id, currency_code]
type: unique
Item:
actAs:
Timestampable: ~
I18n:
fields: [name, description, image]
columns:
id: { type: integer(4), primary: true, autoincrement: true, unsigned: true }
game_id: { type: integer(4), notnull: true, unsigned: true }
product_id: { type: string(100), notnull: true }
price_id: { type: integer(4), notnull: true, unsigned: true }
quantity: { type: integer(4), notnull: true, unsigned: true }
name: { type: string(100), notnull: true }
description: { type: string(255), notnull: true }
image: { type: string(255), notnull: true }
indexes:
it:
fields: item_type
relations:
Game: { onDelete: CASCADE, local: game_id, foreign: id, foreignAlias: GameItems }
Price: { onDelete: CASCADE, local: price_id, foreign: id, foreignAlias: PriceItems }
Ось як я це роблю:
$list = MainItemTable::getInstance()->findByGameId($gameId);
$CampaignMatrix = new CampaignMatrix();
foreach($list as $index => $item) {
$itemAssocForm = new CampaignMatrixForm($CampaignMatrix);
$itemAssocForm->item_id = $item->getId();//Need it in the form as hidden field
$this->embedForm($item->getProductId(), $itemAssocForm);
}
І це так, як я намагаюся отримати значення:
$this->widgetSchema['item_id'] = new sfWidgetFormInputText(array(), array('value' => $this->item_id));//It doesn't get the Id
Але у мене є помилка:
Фатальна помилка: максимальне час виконання 30 секунд перевищено в /vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Relation/Parser.php на лінії 237.
- Якщо я вимкнув price_id у CampaignMatrixForm, помилка не виникала. Як уникнути виконання тих самих даних для кожного ряду елементів у циклі?
- Ідентифікатор елемента відсутній, але мені це потрібно як приховане поле. Як передавати ідентифікатор CampaignMatrix поточного рядка до CampaignMatrixForm?