I have an issue with Sonata admin form...
I would like to insert music in a album with position...
My issue is when I create an album... I can add many as I want AlbumHasMusic... But when I submit my form... Each AlbumHasMusic have a null album whereas music and positions are ok.
How could I put album id to each AlbumHasMusic ?
These are my Entities :
Album:
/**
* Album
*
* #ORM\Table()
* #ORM\Entity(repositoryClass="AppBundle\Entity\AlbumRepository")
* #ORM\HasLifecycleCallbacks()
*/
class Album
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="titre", type="string", length=255)
*/
private $titre;
/**
* #var UploadedFile
*/
private $cover;
/**
* #var String
*
* #ORM\Column(name="filename", type="string", length=255, nullable=true)
*/
private $covername;
/**
*
* #var Array<AlbumHasMusiques>
* #ORM\OneToMany(targetEntity="AppBundle\Entity\AlbumHasMusiques", mappedBy="album", cascade={"persist"})
*/
private $albumHasMusiques;
/**
* #var \DateTime
*
* #ORM\Column(name="updated", type="time", nullable=true)
*/
private $updated;
}
AlbumHasMusic:
/**
* AlbumHasMusiques
*
* #ORM\Table()
* #ORM\Entity(repositoryClass="AppBundle\Entity\AlbumHasMusiquesRepository")
*/
class AlbumHasMusiques
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var Album
*
* #ORM\ManyToOne(targetEntity="Album")
* #ORM\JoinColumn(name="album_id", referencedColumnName="id")
*/
private $album;
/**
* #var Musique
*
* #ORM\ManyToOne(targetEntity="Musique")
* #ORM\JoinColumn(name="musique_id", referencedColumnName="id")
*/
private $musique;
/**
* #var integer
*
* #ORM\Column(name="position", type="integer")
*/
private $position;
}
Music:
/**
* Musique
*
* #ORM\Table()
* #ORM\Entity(repositoryClass="AppBundle\Entity\MusiqueRepository")
* #ORM\HasLifecycleCallbacks()
*/
class Musique
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var \DateTime
*
* #ORM\Column(name="duree", type="time", nullable=true)
*/
private $duree;
/**
* #var \DateTime
*
* #ORM\Column(name="updated", type="time", nullable=true)
*/
private $updated;
/**
* #var string
*/
private $file;
/**
* #var String
*
* #ORM\Column(name="filename", type="string", length=255, nullable=true)
*/
private $filename;
/**
* #var string
*
* #ORM\Column(name="titre", type="string", length=255, nullable=true)
*/
private $titre;
/**
* #var Genre
*
* #ORM\ManyToOne(targetEntity="Genre", inversedBy="musiques")
* #ORM\JoinColumn(name="genre_id", referencedColumnName="id", nullable=false)
*/
private $genre;
/**
* #ORM\ManyToMany(targetEntity="MotClef", inversedBy="musiques")
*/
private $motsClef;
}
I would like to do something like Galeries and media of Sonata Media Bundle.
And this is my AlbumAdmin:
class AlbumAdmin extends Admin
{
/**
* #param FormMapper $formMapper
*/
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('titre')
->add('covername')
->add('updated')
->add('albumHasMusiques', 'sonata_type_collection', array(
'cascade_validation' => true,
'by_reference' => false,
), array(
'edit' => 'inline',
'inline' => 'table',
'sortable' => 'position',
'link_parameters' => array('context' => 'default'),
'admin_code' => 'app.admin.album_has_musiques',
)
)
;
}
/**
* {#inheritdoc}
*/
public function prePersist($album)
{
$album->setAlbumHasMusiques($album->getAlbumHasMusiques());
}
/**
* {#inheritdoc}
*/
public function preUpdate($album)
{
$album->setAlbumHasMusiques($album->getAlbumHasMusiques());
}
}
And AlbumHasMusicAdmin :
class AlbumHasMusiquesAdmin extends Admin
{
/**
* #param FormMapper $formMapper
*/
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('musique', 'sonata_type_model_list', array('required' => true), array(
'link_parameters' => ['context' => 'default'],
))
->add('position', 'hidden')
;
}
}
Do you have any idea ?
I think that you missed something in the addAlbumHasMusiques() function in your album entity : make sure that you wrote it like that :
public function addAlbumHasMusiques(\AppBundle\Entity\AlbumHasMusiques $albumHasMusiques) {
$albumHasMusiques->setAlbum($this); // The important line !!!!
$this->albumHasMusiques[] = $albumHasMusiques;
return $this;
}
Related
I cannot seem to figure out the way to embed forms together, I have used this SO question to try and get close but all I get is an out of memory error.
On the creation of a Buyer I want to add Contacts at the same time. I see examples of checkboxes for this but I want input fields and a contact might not exist.
Also contacts is a general storage for any contact to which they might be part of different buyers / sellers.
/**
*
* #ORM\Table(name="buyer")
* #ORM\Entity
*/
class Buyer
{
/**
* #var int
*
* #ORM\Column(name="id", type="integer", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="name", type="string", length=30, nullable=false)
*/
private $name;
/**
* #var string|null
*
* #ORM\Column(name="address", type="string", length=60, nullable=true)
*/
private $address;
/**
* #var string|null
*
* #ORM\Column(name="city", type="string", length=60, nullable=true)
*/
private $city;
/**
* #var string|null
*
* #ORM\Column(name="state", type="string", length=20, nullable=true)
*/
private $state;
/**
* #var int|null
*
* #ORM\Column(name="zip", type="integer", nullable=true)
*/
private $zip;
/**
* #ORM\OneToMany(targetEntity="App\Entity\BuyerContact", mappedBy="buyer")
*/
protected $contacts;
public function __construct()
{
$this->contacts = new ArrayCollection();
}
...
/**
*
* #ORM\Table(name="buyer_contact", indexes={#ORM\Index(name="fk_buyer", columns={"buyer"}), #ORM\Index(name="fk_contact", columns={"contact"})})
* #ORM\Entity
*/
class BuyerContact
{
/**
* #var int
*
* #ORM\Column(name="id", type="integer", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var Buyer
*
* #ORM\ManyToOne(targetEntity="App\Entity\Buyer", inversedBy="contacts")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="buyer", referencedColumnName="id")
* })
*/
private $buyer;
/**
* #var Contact
*
* #ORM\ManyToOne(targetEntity="App\Entity\Contact")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="contact", referencedColumnName="id")
* })
*/
private $contact;
...
/**
*
* #ORM\Table(name="contact")
* #ORM\Entity
*/
class Contact
{
/**
* #var int
*
* #ORM\Column(name="id", type="integer", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var string|null
*
* #ORM\Column(name="job_title", type="string", length=30, nullable=true)
*/
private $jobTitle;
/**
* #var string|null
*
* #ORM\Column(name="name", type="string", length=60, nullable=true)
*/
private $name;
/**
* #var string|null
*
* #ORM\Column(name="email", type="string", length=120, nullable=true)
*/
private $email;
class BuyerType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('buyer', TextType::class,[
'required'=>true,
'label'=>'Buyer',
'help'=>'The business name of the buyer'
])
->add('address', TextType::class, [
'required'=>false,
'label'=>'Address 1',
'help'=>'Address line one.'
])
->add('city', TextType::class, [
'required'=>false,
'label'=>'City',
])
->add('state', TextType::class,[
'required'=>false,
'label'=>'State',
])
->add('zip', NumberType::class, [
'required'=>false,
'label'=>'Zip',
])
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Buyer::class,
]);
}
}
class BuyerContactType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('buyer')
->add('contact')
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => PublisherContact::class,
]);
}
}
if i understand correctly what you want is to embed form fields:
Basically, what you need is to create 2 different forms, and in the one you want to embed the fields add them like this (you have to put this code in BuyerType form class):
$builder->add('field', BuyerContactType::class, [
// ...
]);
Where BuyerContactType::class is the form that contains the fields you want to embed. (or viceversa BuyerContactType to BuyerType)
Hope it helps, don't know if understand the question correctly
This was my mistake as the entities were generated for an existing application. All I had to do was configure the ManyToMany unidirectional relationship between the Buyer and contacts and everything works as intended.
I'm facing a big problem with Doctrine when i'm requesting a table with a composite primary key referencing foreign keys.
I have a 3 entities:
Library(idLibrary,adress), Book(idBook,title,pageCount), Container(idLibrary,idBook, quantity).
Everything is generated without any errors but when i'm doing findAll() request on my Container repository my browser freezes and nothing is showed like it was stuck in a loop (there 3 rows in my Container table).
class Bibliotheque
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #ORM\Column(name="name", type="string", length=60)
*/
private $name;
/**
* #ORM\Column(name="adress", type="string", length=60)
*/
private $adress;
}
class Conteneur
{
/**
* Many Containers have One library.
* #ORM\Id
* #ORM\OneToOne(targetEntity="Bibliotheque")
* #ORM\JoinColumn(name="libraryId", referencedColumnName="id")
*/
private $library;
/**
* One Container has One book.
* #ORM\Id
* #ORM\OneToOne(targetEntity="Livre")
* #ORM\JoinColumn(name="bookId", referencedColumnName="id")
*/
private $book;
/**
* #ORM\Column(name="quantity", type="integer")
*/
private $quantity;
}
class Livre
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #ORM\Column(name="title", type="string", length=255)
*/
private $title;
/**
* #ORM\Column(name="pageCount", type="integer")
*/
private $pageCount;
/**
* Un livre a plusieurs auteurs
* #ORM\ManyToMany(targetEntity="Auteur")
* #ORM\JoinTable(name="books_authors",
* joinColumns={#ORM\JoinColumn(name="book_id", referencedColumnName="id")},
* inverseJoinColumns={#ORM\JoinColumn(name="author_id", referencedColumnName="id")}
* )
*/
private $authors;
}
class Auteur
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #ORM\Column(name="name", type="string", length=60)
*/
private $name;
/**
* #ORM\Column(name="surname", type="string", length=60)
*/
private $prenom;
/**
* #ORM\Column(name="birthDate", type="date")
*/
private $birthDate;
}
firstly, please use only French or English for class name and variable.
Add id inside class "Container" and remove annotation #ORM\id for attributes "library" and "book"
Define attribute "authors" with ArrayCollection and add method getAuthors(), addAuthor(Author $author), removeAuthor(Author $author)
And rename the tables name => "name_id" not "nameId"
look documention http://symfony.com/doc/current/doctrine.html
class Library
{
/**
* #var integer $id
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string $name
*
* #ORM\Column(name="name", type="string", length=60)
*/
private $name;
/**
* #var string $address
*
* #ORM\Column(name="address", type="string", length=60)
*/
private $address;
}
class Container
{
/**
* #var integer $id
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* Many Containers have One library.
*
* #ORM\OneToOne(targetEntity="Library")
* #ORM\JoinColumn(name="library_id", referencedColumnName="id")
*/
private $library;
/**
* One Container has One book.
*
* #ORM\OneToOne(targetEntity="Book")
* #ORM\JoinColumn(name="book_id", referencedColumnName="id")
*/
private $book;
/**
* #ORM\Column(name="quantity", type="integer")
*/
private $quantity;
}
class Book
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string $title
*
* #ORM\Column(name="title", type="string", length=255)
*/
private $title;
/**
* #var string $pageCount
*
* #ORM\Column(name="page_count", type="integer")
*/
private $pageCount;
/**
* A book have many authors
*
* #var ArrayCollection $authors
*
* #ORM\ManyToMany(targetEntity="Auteur")
* #ORM\JoinTable(name="books_authors",
* joinColumns={#ORM\JoinColumn(name="book_id", referencedColumnName="id")},
* inverseJoinColumns={#ORM\JoinColumn(name="author_id", referencedColumnName="id")}
* )
*/
private $authors;
/**
* #return ArrayCollection
*/
public function getAuthors()
{
return $this->authors;
}
/**
* #param Author $author
*
* #return $this
*/
public function addAuthor(Author $author)
{
$this->authors->add($author);
return $this;
}
/**
* #param Author $author
*
* #return $this
*/
public function removeAuthor(Author $author)
{
$this->authors->removeElement($author);
return $this;
}
}
class Author
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string $firstname
*
* #ORM\Column(name="firstname", type="string", length=60)
*/
private $firstname;
/**
* #var string $lastname
*
* #ORM\Column(name="lastname", type="string", length=60)
*/
private $lastname;
/**
* #var DateTime $birthDate
*
* #ORM\Column(name="birthDate", type="date")
*/
private $birthDate;
}
I have two Entities
Contacts:
<?php
namespace AppBundle\Entity;
use...
/**
* #ORM\Entity
* #UniqueEntity(
* fields={"client", "name", "surname"},
* errorPath="name",
* message="This contact is already in use for this client."
* )
* #ORM\Table(name="contact")
*/
class Contact
{
/**
* #ORM\Column(name="id", type="integer")
* #ORM\Id()
* #ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* #var integer
* #Assert\NotBlank()
* #ORM\ManyToOne(targetEntity="Client")
* #ORM\JoinColumn(name="client_id", referencedColumnName="client_id", nullable=false)
*/
private $client;
/**
* #ORM\Column(type="string", length=255, options={"default": ""}, nullable=true)
* #Assert\NotBlank()
*/
protected $name;
/**
* #ORM\Column(type="string", length=255, options={"default": ""}, nullable=true)
* #Assert\NotBlank()
*/
protected $surname;
/**
* #var integer
*
* #ORM\ManyToOne(targetEntity="AppBundle\Entity\Email")
* #ORM\JoinColumn(name="email_id", referencedColumnName="id")
*/
protected $email;
...
}
and Emails:
class Email
{
/**
* #ORM\Column(name="id", type="integer")
* #ORM\Id()
* #ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* #var integer
*
* #ORM\ManyToOne(targetEntity="Client")
* #ORM\JoinColumn(name="client_id", referencedColumnName="client_id")
*/
private $client;
/**
* #var string
*
* #ORM\Column(name="email", type="string", nullable=false)
* #Assert\Email(
* message = "The email '{{ value }}' is not a valid email.",
* checkMX = true
* )
*/
protected $email;
...
}
I am using the "sonata admin bundle" to generate the GUIs.
For the ContactAdmin i have the following snippet:
...
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('email', 'sonata_type_model_list', array(
// 'query' => $query,
'label' => 'E-Mail',
'compound' => true,
'by_reference' => true,
))
The problem: When I add a new entry or choose one entry from the list - I do not want to select the "client" again. It has similar to the already choosen one.
I was able to access the pcode-Parameter in order to see if I have a parent class (Contact-Class for the Email-Class) - but how can I access the data which client has been choosen/selected by the parent-class?
I have a form with fields that are translated. One of this fields is a file, witch must to be uploaded (each language have different file).
I am using 'stof/doctrine-extensions-bundle' and 'a2lix/translation-form-bundle' and for uploading files 'vich/uploader-bundle' with symfony2.
found this https://github.com/a2lix/TranslationFormBundle/issues/83, but it's not working
Maximum function nesting level of '100' reached, aborting!
My Catalog entity:
/**
* Catalog.
*
* #ORM\Entity()
* #ORM\Table("catalog")
*
* #Vich\Uploadable
*
* #Gedmo\TranslationEntity(class="Entity\Catalog\CatalogTranslation")
*/
class Catalog
{
/**
* #var int
*
* #ORM\Column(type="integer")
* #ORM\Id()
* #ORM\GeneratedValue()
*/
private $id;
/**
* #var string
*
* #ORM\Column()
*
* #Gedmo\Translatable()
*
* #Assert\NotBlank()
*/
private $name;
/**
* #var File
*
* #Vich\UploadableField(mapping="product_image", fileNameProperty="imageName")
*
* #Assert\Image(maxSize = "4M")
*/
protected $imageFile;
/**
* #var string
*
* #ORM\Column(nullable=true)
* #Gedmo\Translatable()
*/
protected $imageName;
/**
* #ORM\OneToMany(
* targetEntity="CatalogTranslation",
* mappedBy="catalog",
* cascade={"persist", "remove"}
* )
*/
private $translations;
}
Also tried this when building form:
->add('imageName', 'a2lix_translationsForms', [
'form_type' => 'vich_file',
'form_options' => array(
'required' => true,
'mapping' => 'product_image',
'allow_delete' => true,
'download_link' => true,
)
])
My guess is that CatalogTranslation should be the class defined as Uploadable as otherwise it will probably confuse VichUploaderBundle.
I'd try something like this:
<?php
/**
* Catalog.
*
* #ORM\Entity()
* #ORM\Table("catalog")
*
* NOT uploadable
*
* #Gedmo\TranslationEntity(class="Entity\Catalog\CatalogTranslation")
*/
class Catalog
{
/**
* #var int
*
* #ORM\Column(type="integer")
* #ORM\Id()
* #ORM\GeneratedValue()
*/
private $id;
/**
* #var string
*
* #ORM\Column()
*
* #Gedmo\Translatable()
*
* #Assert\NotBlank()
*/
private $name;
/**
* #var string
*
* #ORM\Column(nullable=true)
* #Gedmo\Translatable()
*/
protected $imageName;
/**
* #ORM\OneToMany(
* targetEntity="CatalogTranslation",
* mappedBy="catalog",
* cascade={"persist", "remove"}
* )
*/
private $translations;
}
class CatalogTranslation
{
// ... as usual
/**
* #var File
*
* #Vich\UploadableField(mapping="product_image", fileNameProperty="imageName")
*
* #Assert\Image(maxSize = "4M")
*/
protected $imageFile;
protected $imageName;
}
I have 5 Entities
Entity\Book:
class Book
{
/**
* #var integer
*
* #ORM\Column(name="b_id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $bId;
/**
* #var string
*
* #ORM\Column(name="b_foto", type="string", length=255, nullable=true)
*/
private $bFoto;
/**
* #var string
*
* #ORM\Column(name="b_title", type="string", length=255, nullable=false)
*/
private $bTitle;
public $author;
public $heading;
}
Entity\Author
/**
* Author
*
* #ORM\Table(name="author")
* #ORM\Entity
*/
class Author
{
/**
* #var integer
*
* #ORM\Column(name="a_id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $aId;
/**
* #var string
*
* #ORM\Column(name="a_firstname", type="string", length=100, nullable=false)
*/
private $aFirstname;
/**
* #var string
*
* #ORM\Column(name="a_lastname", type="string", length=100, nullable=false)
*/
private $aLastname;
}
Entity\Heading
/**
* Heading
*
* #ORM\Table(name="heading")
* #ORM\Entity
*/
class Heading
{
/**
* #var integer
*
* #ORM\Column(name="h_id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $hId;
/**
* #var string
*
* #ORM\Column(name="h_title", type="string", length=100, nullable=false)
*/
private $hTitle;
}
Entity\BooksAuthor
/**
* BooksAuthor
*
* #ORM\Table(name="books_author", indexes={#ORM\Index(name="book_in", columns={"b_id"}), #ORM\Index(name="author_in", columns={"a_id"})})
* #ORM\Entity
*/
class BooksAuthor
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var \AppBundle\Entity\Book
*
* #ORM\ManyToOne(targetEntity="AppBundle\Entity\Book")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="b_id", referencedColumnName="b_id")
* })
*/
private $b;
/**
* #var \AppBundle\Entity\Author
*
* #ORM\ManyToOne(targetEntity="AppBundle\Entity\Author")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="a_id", referencedColumnName="a_id")
* })
*/
private $a;
}
Entity\BooksHeading
class BooksHeading
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var \AppBundle\Entity\Heading
*
* #ORM\ManyToOne(targetEntity="AppBundle\Entity\Heading")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="h_id", referencedColumnName="h_id")
* })
*/
private $h;
/**
* #var \AppBundle\Entity\Book
*
* #ORM\ManyToOne(targetEntity="AppBundle\Entity\Book")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="b_id", referencedColumnName="b_id")
* })
*/
private $b;
}
I use SonataAdmin and when I update my Entity\Book I want to update and another Entities.
That`s my BookAdmin
namespace AppBundle\Admin;
use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Form\FormMapper;
class BookAdmin extends Admin
{
// Fields to be shown on create/edit forms
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('bTitle', null , array('label' => 'Название'))
->add('author', 'sonata_type_model', array('class' => 'AppBundle\Entity\Author',
'label'=>"Авторы",
'multiple'=>true,
'required'=>false,
'multiple'=>true,
'expanded'=> true,
'by_reference' => false,),
array(
'edit' => 'inline',
'inline' => 'table',
'sortable' => 'position')
)
->add('heading', 'sonata_type_model', array('class' => 'AppBundle\Entity\Heading',
'label'=>'Рубрика',
'required'=>false,
'multiple'=>true,
'expanded'=> true,
'by_reference' => false,),
array(
'edit' => 'inline',
'inline' => 'table',
'sortable' => 'id',))
->add('bFoto','file',array('label'=>'Обложка',
'data_class'=> null,
'required'=>false,
))
;
}
// Fields to be shown on filter forms
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
//->add('author', null , array('label' => 'Автор',
// 'class' => 'AppBundle\Entity\BookAuthor',
// ))
//->add('heading', null, array('label' => 'Рубрика',
//'class' => 'AppBundle\Entity\BookHeading',
//))
;
}
// Fields to be shown on lists
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->addIdentifier('b_id', null, array('label' => 'ID'))
->add('bTitle', null , array('label' => 'Название'))
;
}
}
Can you help me?
You need to indicate the cascade type in your entities BooksHeading and BooksAuthor,
Try this:
#ORM\ManyToOne(targetEntity="AppBundle\Entity\Heading", casccade="persist")