Symfony1 Admin Generator
Format generator.yml
● By default, the columns of the list view are the columns defined in schema.yml.
● The fields of the new and edit views are the one defined in the form associated with the model. With generator.yml, you can choose which fields are displayed (display: []), add fields of your own
Ex:display: [_currencyPair, ...] //Column followed with ( “_”) will display the
partial template, usually a file like _currency_pair.php .
display: [=currencyPair, ...] //Column followed with ( “=”) will display the column with anchor link (<a />) to edit the particular record.
display: [~article_link, …] //Like class file, we have some thing like components.class.php file, will include that.
(You may need to split a partial into a logic part and a presentation part. In such a case, you should use a component).
fields:
status: { name: Is Active}
currency_id_pair: {name: Currency Pair ID}
campaign_point: {name: My Header}
View :
This is a general principle:
Any settings that are set for the whole module under the fields key, can be overridden by view-specific areas. The overriding rules are the following:
● new and edit inherits from form which inherits from fields
● list inherits from fields
● filter inherits from fields
Setting a Custom Title, Content/Layout of view.
edit:
title: Edit Article %%currency_pair%% (%%campaign_currency_values_id%%)
Output:http://xyz/admin_dev.php/abc/edit/campaign_currency_values_id/26
layout: stacked
params: |
%%=content%%<br />
(sent by %%author%% on %%created_at%% about %%article_link%%)
Setting a Default Sort Field in the list View
list:
sort: created_at
## Alternative syntax, to specify a sort order
sort: [created_at, desc]
Customizing the Pagination:
config:
list:
max_per_page: 5
● Using a Join to Speed Up Page Delivery
1.By default, the administration generator uses a simple doSelect() to retrieve a list of records.
2. But, if you use related objects in the list, the number of database queries required to display the list may rapidly increase.
Ex: If you want to display the name of the article in a list of comments, an additional query is required for each post in the list to retrieve the related Article object
● So you may want to force the pager to use a doSelectJoinXXX() method to optimize the number of queries.
config:
list:
peer_method: doSelectJoinArticle
Defining Interactions for Each View, object_actions:
_edit: ~
_delete: ~
addcomment: { label: Add a comment, action: addComment }
● Clicking it triggers a call to the addComment action in the current module.
Ex: http://xyz/admin_dev.php/abc/addComment/campaign_currency_values_id/25
So need to implement the code :
public function executeAddComment($request) {
$comment = new Comment();
$comment->setArticleId($request->getParameter('id'));
$comment->save();
$this->redirect('comments_edit', $comment);
}
Questions