dev-master
9999999-devImproved version of the symfony1 generator - Propel flavored
MIT
The Requires
by Desarrollo CeSPI
Improved version of the symfony1 generator - Propel flavored
The pmPropelGeneratorPlugin
decouples the admin generator and the forms
framework by delegating the module behavior to the form. Also, adds to the
admin module the show action., (*1)
{ "require": { "desarrollo-cespi/pm-propel-generator-plugin": "dev-master" } }
Or using git, from source., (*2)
Clear the cache, (*3)
From now on you can generate-admin with the basic theme:, (*4)
$ php symfony propel:generate-admin <app> ClassName --theme=basic
generator: class: pmPropelGenerator param: # ... theme: basic # ...
get{$action}Fieldsets
method in the form:class Person extends sfFormPropel { // ... public function getNewFieldsets() { return array( 'NONE' => array('first_name', 'last_name'), 'Address' => array('street', 'number', 'city_id') ); } public function getEditFieldsets() { return $this->getNewFieldsets(); } }
Only for New and Edit actions (show action is like a list view)., (*5)
get{$action}Layout
method in the form:class Person extends sfFormPropel { // ... public function getNewLayout() { return 'tabbed'; // or 'folded' } public function getEditLayout() { return 'folded'; // or 'tabbed' } } Also you can create another layouts, creating a partial. I.E., tabbed layout is coded in _form_tabbed.php and _show_form_tabbed.php. * Fields and display configuration through the form for new, edit and show contexts. * The forms are displayed in tables rather than divs (as originally in forms) and thus the partials are less than in the standard generator. * Form formatters are used if defined. * Object actions can be forbidden if a method is defined in the object. IE: ```php class Person extends BasePerson { /** * this method will be used to forbid the edit action in the generator */ public function canEdit($sf_user) { return !$this->getLock(); } }
The method takes one argument: the user., (*6)
new action can be forbidden defining the canNew method on Peer class. IE:, (*7)
class PersonPeer extends BasePersonPeer { /** * this method will be used to forbid the new action in the generator */ public function canNew($sf_user) { // do something... return true; } }
list: object_actions: _edit: show_when: canEdit # ...
list: fields: document_type: peer_column: DocumentTypePeer::NAME peer_method: doSelectJoinDocumentType display: [first_name, last_name, document_type, document_number]
list: multiple_sort: true
New flash messages, (*8)
Top actions, (*9)
If you want to display the form or list actions above the form or the list, you can set the 'use_top_actions' to true in the 'list' and 'form' section of the generator.yml, (*10)
list: use_top_actions: true form: use_top_actions: true
If you want to display the paginator above the list set the 'use_top_pagination' to true in the 'list' section., (*11)
list: use_top_pagination: true
<tr class="sf_admin_row <?php include_partial('sf_admin_row_extra_classes', array('object' => $object))"> ... </tr>
Use it like this:, (*12)
show: title: Showing something layout: tabbed display: First tab: [first_name, last_name] Second tab: [_full_id]
As you can see, you can use partials., (*13)
public function configure() { $pm_formatter_table = new pmWidgetFormSchemaFormatterTable($this); $this->getWidgetSchema()->addFormFormatter("pm_table", $pm_formatter_table); $this->getWidgetSchema()->setFormFormatterName("pm_table"); }
Export to CSV or EXCEL (requires sfPhpExcelPlugin to work). See the EXPORTATION_DOCUMENTATION
file for complete documentation., (*14)
customEdit:, (*15)
If you're trying to modify an object with a customized form (which is not the same that is used in the 'edit' action) this plugin provides a customEdit template that use the following variables:, (*16)
custom_title : The title of the page., (*17)
The 'simpleProcessForm' and 'getObjectFromRequest' methods in the moduleAction class may came in handy when using this., (*18)
Here's a little example of how to use this:, (*19)
public function executeEditInternalAreas(sfWebRequest $request) { $this->Document = $this->getRoute()->getObject(); $this->form = $this->configuration->getEditInternalAreasForm($this->Document); $this->dbObject = $this->form->getObject(); $this->custom_form_action = 'document/updateInternalAreas'; $this->custom_title = 'Edit internal areas of the document'; $this->setTemplate('customEdit'); } public function executeUpdateInternalAreas(sfWebRequest $request) { $this->form = $this->configuration->getEditInternalAreasForm($this->getObjectFromRequest('document')); $this->dbObject = $this->form->getObject(); $this->custom_form_action = 'document/updateInternalAreas'; $this->custom_title = 'Edit internal areas of the document'; $this->simpleProcessForm($request, $this->form, '@document'); $this->setTemplate('customEdit'); }
Improved version of the symfony1 generator - Propel flavored
MIT