Skip to content

Instantly share code, notes, and snippets.

@rande
Created February 4, 2011 08:57
Show Gist options
  • Save rande/810894 to your computer and use it in GitHub Desktop.
Save rande/810894 to your computer and use it in GitHub Desktop.
<?php
/*
* This file is part of the Sonata package.
*
* (c) Thomas Rabaix <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sonata\NewsBundle\Admin;
use Sonata\BaseApplicationBundle\Admin\EntityAdmin as Admin;
use Sonata\BaseApplicationBundle\Form\FormMapper;
use Sonata\BaseApplicationBundle\Admin\FieldDescription;
use Sonata\BaseApplicationBundle\Filter\Filter;
use Application\Sonata\NewsBundle\Entity\Comment;
class PostAdmin extends Admin
{
protected $class = 'Application\Sonata\NewsBundle\Entity\Post';
protected $formOptions = array(
'validation_groups' => 'admin'
);
protected $list = array(
'title' => array('identifier' => true),
'author',
'enabled',
'comments_enabled',
);
protected $form = array(
// 'author' => array('edit' => 'inline'),
'enabled',
// 'title',
'abstract',
'content',
'tags' => array('form_field_options' => array('expanded' => true)),
'comments_close_at',
'comments_enabled',
'comments_default_status',
'comments' => array('edit' => 'inline', 'inline' => 'table')
);
protected $formGroups = array(
'General' => array(
'fields' => array('author', 'title', 'abstract', 'content'),
),
'Tags' => array(
'fields' => array('tags'),
),
'Options' => array(
'fields' => array('enabled', 'comments_close_at', 'comments_enabled', 'comments_default_status'),
'collapsed' => true
)
);
protected $filterFields = array(
'title',
'enabled',
'tags' => array('filter_field_options' => array('expanded' => true, 'multiple' => true))
);
// don't know yet how to get this value
protected $baseControllerName = 'SonataNewsBundle:PostAdmin';
public function configureFormFields(FormMapper $form)
{
$form->add('author', array(), array('edit' => 'list'));
$form->add('title');
$form->add('comments_default_status', array('choices' => Comment::getStatusList()), array('type' => 'choice'));
$form->add(new \Symfony\Component\Form\ChoiceField('comments_default_status', array('choices' => Comment::getStatusList())));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment