0

I learn SonataAdminBundle with this tutorial: http://sftuts.com/doc/jobeet/en/the-admin-generator

but instead of:

enter image description here

I have empty values:

enter image description here

Also in form, I have only submit button, but if I click this button then I have error:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'type' cannot be null

Maybe is better tutorial for SonataAdminBundle?

EDIT:

<?php

//src/SfTuts/JobeetBundle/Admin/CategoryAdmin.php

namespace SfTuts\JobeetBundle\Admin;

use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;

class CategoryAdmin extends Admin
{
    protected $list = array(
        'id' => array('identifier' => true),
        'name',
    );
    protected $form = array(
        'name',
    );
    protected $filter = array(
        'name',
    );
}
j0k
  • 22,600
  • 28
  • 79
  • 90
Tony Evyght
  • 2,385
  • 6
  • 20
  • 19

1 Answers1

1

You could read this piece of documentation. Your version of the tutorial could be outdated. http://sonata-project.org/bundles/admin/master/doc/index.html

Try this code:

use Sonata\AdminBundle\Admin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Validator\ErrorElement;
use Sonata\AdminBundle\Form\FormMapper;
class CategoryAdmin extends Admin
{
    /**
     * @param \Sonata\AdminBundle\Form\FormMapper $formMapper
     * @return void
     */
    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->add('name')
            ;
    }

    /**
     * @param \Sonata\AdminBundle\Datagrid\DatagridMapper $datagridMapper
     * @return void
     */
    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper
            ->add('name');
    }

    /**
     * @param \Sonata\AdminBundle\Datagrid\ListMapper $listMapper
     * @return void
     */
    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->add('id')
            ->addIdentifier('name');
    }
}
Amit
  • 3,644
  • 9
  • 38
  • 49