PHP code example of aschaeffer / sonata-editable-list-bundle
1. Go to this page and download the library: Download aschaeffer/sonata-editable-list-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
aschaeffer / sonata-editable-list-bundle example snippets
class User {
/**
* @Listable(code="user_gender")
* @ORM\ManyToOne(
* targetEntity="SonataEditableItem", cascade={"persist"}
* )
* @ORM\JoinColumn(name="gender_id", referencedColumnName="id")
*
* @var SonataEditableItem
*/
protected $gender;
/**
* @var SonataEditableItem[] $interests
* @ORM\ManyToMany(targetEntity="SonataEditableItem")
* @ORM\JoinTable(name="users_interests",
* joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="item_id", referencedColumnName="id")}
* )
* @Listable(code="user_interests")
*/
protected $interests;
}
use Aschaeffer\SonataEditableListBundle\Form\Type\ItemSelectorType;
class UserAdmin {
protected function configureFormFieldsProperties(FormMapper $formMapper) {
$formMapper
->add('gender', ItemSelectorType::class,
[
'model_manager' => $this->getModelManager(),
'class' => SonataEditableItem::class,
' 'multiple' => true,
]
)
}
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagrid
->add('gender', null, [],
ItemSelectorType::class,
[
'model_manager' => $this->getModelManager(),
'class' => SonataEditableItem::class,
'multiple' => true,
'field_name' => 'gender',
'class_name' => User::class,
]
)
->add('gender', null, [],
ItemSelectorType::class,
[
'model_manager' => $this->getModelManager(),
'class' => SonataEditableItem::class,
'multiple' => true,
'field_name' => 'interests',
'class_name' => User::class,
]
)
}
}