GithubHelp home page GithubHelp logo

Comments (2)

rande avatar rande commented on May 28, 2024

this should be fixed with the last version

from sonataadminbundle.

iceye avatar iceye commented on May 28, 2024

Having almost the same problem:

"An exception has been thrown during the rendering of a template ("[Semantical Error] line 0, col 24 near 'id) as cnt FROM': Error: Class Custom\Boundle\Entity\User has no field or association named id") in SonataAdminBundle:CRUD:base_list.html.twig at line 28."

My Entity:

User:

type: entity
  table: user
  fields:
    iduser:
      id: true
      type: integer
      unsigned: false
      nullable: false
      generator:
        strategy: IDENTITY
    name:
      type: string
      length: 45
      fixed: false
      nullable: false
    surname:
      type: string
      length: 45
      fixed: false
      nullable: false
    email:
      type: string
      length: 45
      fixed: false
      nullable: false
    mobile:
      type: string
      length: 45
      fixed: false
      nullable: false
    login:
      type: string
      length: 45
      fixed: false
      nullable: false
    password:
      type: string
      length: 45
      fixed: false
      nullable: false
  lifecycleCallbacks: {  }

my UserAdmin:

class UserAdmin extends Admin{

 protected $list = array(
        'iduser' => array('identifier' => true),
        'name',
        'surname',
        'email',
         'mobile',
         'login',
         'password'
    );

    protected $form = array(
        'name'=> array('form_field_options' => array('required' => true)),
        'surname'=> array('form_field_options' => array('required' => true)),
        'email'=> array('form_field_options' => array('required' => true)),
         'mobile'=> array('form_field_options' => array('required' => true)),
         'login'=> array('form_field_options' => array('required' => true)),
         'password'=> array('form_field_options' => array('required' => true))
    );

    protected $filter = array(
        'name',
        'surname',
        'email',
         'mobile',
         'login',
         'password'
    );
    protected $maxPerPage = 10;
}

When trying to access create in admin:

Method "id" for object "Custom\Boundle\Entity\User" does not exist in SonataAdminBundle:CRUD:base_edit.html.twig at line 31

The service declaration:

services:
   sonata.myservice.admin.user:
      class: Custom\AdminBundle\Admin\UserAdmin
      tags:
        - { name: sonata.admin, manager_type: orm, group: custom_admin, label: user }
      arguments: [null, Custom\Bundle\Entity\User, CustomAdminBundle:UserAdmin]   

The php entity:

/**
 * Custom\Bundle\Entity\User
 *
 * @orm:Table(name="user")
 * @orm:Entity
 */
class User
{
    /**
     * @var integer $iduser
     *
     * @orm:Column(name="iduser", type="integer", nullable=false)
     * @orm:Id
     * @orm:GeneratedValue(strategy="IDENTITY")
     */
    private $iduser;

    /**
     * @var string $name
     *
     * @orm:Column(name="name", type="string", length=45, nullable=false)
     */
    private $name;

    /**
     * @var string $surname
     *
     * @orm:Column(name="surname", type="string", length=45, nullable=false)
     */
    private $surname;

    /**
     * @var string $email
     *
     * @orm:Column(name="email", type="string", length=45, nullable=false)
     */
    private $email;

    /**
     * @var string $mobile
     *
     * @orm:Column(name="mobile", type="string", length=45, nullable=false)
     */
    private $mobile;

    /**
     * @var string $login
     *
     * @orm:Column(name="login", type="string", length=45, nullable=false)
     */
    private $login;

    /**
     * @var string $password
     *
     * @orm:Column(name="password", type="string", length=45, nullable=false)
     */
    private $password;

   //+++Getters and Setters
}

from sonataadminbundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.