14
Symfony1 Admin Generator

Symfony Admin Generator - generator.yml

Embed Size (px)

DESCRIPTION

Tells most of the options that are available in symfony admin generator, generator.yml file, That makes the admin panel creation easy

Citation preview

Page 1: Symfony Admin Generator - generator.yml

Symfony1 Admin Generator

Page 2: Symfony Admin Generator - generator.yml
Page 3: Symfony Admin Generator - generator.yml

Format generator.yml

Page 4: Symfony Admin Generator - 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).

Page 5: Symfony Admin Generator - generator.yml

fields:

status: { name: Is Active}

currency_id_pair: {name: Currency Pair ID}

campaign_point: {name: My Header}

View :

Page 6: Symfony Admin Generator - generator.yml

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

Page 7: Symfony Admin Generator - generator.yml

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

Page 8: Symfony Admin Generator - generator.yml

layout: stacked

params: |

%%=content%%<br />

(sent by %%author%% on %%created_at%% about %%article_link%%)

Page 9: Symfony Admin Generator - generator.yml

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

Page 10: Symfony Admin Generator - generator.yml

● 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

Page 11: Symfony Admin Generator - generator.yml

Defining Interactions for Each View, object_actions:

_edit: ~

_delete: ~

addcomment: { label: Add a comment, action: addComment }

Page 12: Symfony Admin Generator - generator.yml

● 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);

}

Page 13: Symfony Admin Generator - generator.yml

Questions

Page 14: Symfony Admin Generator - generator.yml