Symfony Admin Generator Reference Card

ADVERTISEMENT

» symfony admin generator reference card 1.0 «
Command Line
Presentation
Fields
generator:
Options in this order: <APP> <MODULE> <OBJECT>
Parameters
class:
sfPropelAdminGenerator
$ symfony propel-init-admin backend post Post
fields:
param:
$ symfony propel-init-admin backend comment Comment
my_field:
model_class:
Post
name:
## Field label/header
theme:
mytheme
## custom theme
Generated code (can be overridden per module)
help:
## Tooltip, displays when requested
css:
admin/mystylesheet
## custom css
type:
## for edit view only, see below
accessible in cache/backend/<ENV>/modules/<MODULE>
credentials: ## Classic AND/OR credentials array
Display (ordering and grouping)
Actions
Templates
params:
## html options, depending on the tag
create -> edit
_edit_actions.php
list view
Cascade
delete
_edit_footer.php
The equal sign (=) selects the field holding the hyperlink to the edit view
First declaration covers the whole module
edit
_edit_header.php
list:
can be specialized for each view
index -> list
_filters.php
## tabular layout
fields:
list
_list_actions.php
display: [=title, author_id, created_at]
author:
{ name: Author }
save -> edit
_list_footer.php
list:
_list_header.php
Methods
## stacked layout
fields:
_list_td_actions.php
public handleErrorEdit()
layout:
stacked
author: { help: This is the author of the comment }
_list_td_stacked.php
display: [title, author_id, created_at]
protected save<OBJECT>()
edit:
_list_td_tabular.php
protected delete<OBJECT>()
params: |
fields:
_list_th_tabular.php
protected update<OBJECT>FromRequest()
<strong>%%=title%%</strong>
author: { name: Author of the comment }
_list_th_stacked.php
protected get<OBJECT>OrCreate()
by %%author%% (issued on %%created_at%%)
Input types
editSuccess.php
Stacked layout uses display setting for the column headers (and sorting)
protected processFilters()
listSuccess.php
fields:
protected processSort()
edit view
my_field:
protected addFiltersCriteria()
edit:
type:
protected addSortCriteria()
## ungrouped
plain
## No input
display:
[title, author_id, created_at]
generator.yml
input_tag
## Default for text, numeric
textarea_tag
## Default for longvarchar
generator:
## grouped
input_date_tag ## Default for date and timestamp
class:
sfPropelAdminGenerator
display:
select_tag
## Default for foreign keys
param:
"NONE":
[id]
## And for booleans
model_class:
Post
"Group1": [title, body]
checkbox_tag
theme:
default
"Group2": [created_at]
radiobutton_tag
Groups with label "NONE" have no label
admin_input_upload_tag
fields:
Usual params
author_id:
{ name: Post author }
Additional list settings
fields:
Filters
my_field:
list:
params:
title:
symfony blog posts
filters:
disabled=true
display:
[title, author_id, category_id]
- title
## text filter, accepts * as wildcard
date_format='MM/dd/yy' ## For dates
fields:
- author
## foreign_key filter, displays select
include_blank=true
## For select tags
published_on: { params: date_format='dd/MM/yy' }
- created_at
## date filter from... to...
include_custom=Choose from the list
layout:
stacked
- is_admin
## boolean filter, yes/no/yes or no
size=45x5
## For textareas
params: |
Pagination
rich=true
%%is_published%%<strong>%%=title%%</strong><br />
max_per_page: 10
## maximum number of records per page
tinymce_options=height:150
<em>by %%author%% in %%category%%
Sorting
(%%published_on%%)</em><p>%%content_summary%%</p>
Special fields
filters:
[title, category_id, is_published]
sort: created_at
## sort column (ascending order by default)
max_per_page:
2
sort: [created_at, desc]
## desc sort order
Custom fields
Fields not defined in the schema.xml but for which a custom getter and/or setter were defined in the
Interactions
edit:
model.
title:
Editing post "%%title%%"
list:
modules/post/config/generator.yml
Default actions
display:
display:
[nb_comments]
"Post":
[title, category_id, content]
list:
fields:
"Workflow":
[author_id, is_published, created_on]
object_actions:
nb_comments:
{ name: Number of comments }
fields:
_edit:
-
category_id:
{ params: disabled=true }
_delete:
-
public function getNbComments()
apps/lib/model/Post.php
content:
actions:
{
params:
rich=true tinymce_options=height:150
_create:
-
return count($this->getComments());
author_id:
edit:
}
params:
size=5 include_custom=Choose an author
actions:
is_published: { credentials: [[admin, superdamin]] }
Partial fields
_list:
-
created_on:
{ type: plain, params: date_format='dd/MM' }
_save:
-
Fields declared with a _ prefix in the display: key refer to a partial in the module's template/ dir.
_save_and_add: -
Use the name without prefix under the fields: key.
Validation & Repopulation
_delete:
-
list:
modules/comment/config/generator.yml
display:
[_post_link]
Parameters
methods:
apps/backend/modules/post/validate/edit.yml
fields:
post:
actions:
post_link:
{ name: Related Post }
- "post{title}"
my_action:
- "post{body}"
name:
Add a comment
<php echo link_to(
modules/comment/templates/_post_link.php
names:
action:
addComment
$comment->getPost()->getTitle(),
post{title}:
icon:
backend/addcomment.png
'post/edit?id='.$comment->getPostId()
required:
Yes
only_for:
edit
## Restrict to edit or create
) ?>
required_msg: You must provide a title
params:
class=foobar confirm=Are you sure?
Partials gain automatic access to the current object $<object>.
post{body}:
credentials: [[admin, superuser], owner]
required:
No
validators:
[antiSpamValidator, MyStringValidator]
fillin:
activate:
on

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go