PHP code example of idci / simple-metadata-bundle
1. Go to this page and download the library: Download idci/simple-metadata-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/ */
idci / simple-metadata-bundle example snippets
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
...
new IDCI\Bundle\SimpleMetadataBundle\IDCISimpleMetadataBundle(),
);
}
/**
* @var Metadata
*
* @ORM\OneToOne(targetEntity="IDCI\Bundle\SimpleMetadataBundle\Entity\Metadata", cascade={"all"})
* @ORM\JoinColumn(name="metadata_id", referencedColumnName="id", onDelete="SET NULL", nullable=true)
*/
private $metadata;
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
...
->add('metadata', 'related_to_one_metadata', array(
'data' => $builder->getData()->getMetadata()
))
...
;
}
/**
* @var array<Metadata>
*
* @ORM\ManyToMany(targetEntity="IDCI\Bundle\SimpleMetadataBundle\Entity\Metadata", cascade={"all"})
* @ORM\JoinTable(name="my_entity_metadata",
* joinColumns={@ORM\JoinColumn(name="my_entity_id", referencedColumnName="id", onDelete="cascade")},
* inverseJoinColumns={@ORM\JoinColumn(name="metadata_id", referencedColumnName="id", unique=true, onDelete="cascade")}
* )
*/
private $metadatas;
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
...
->add('metadatas', 'related_to_many_metadata')
...
;
}
/**
* @var string
*
* @ORM\Column(name="metadata", type="textarea")
*/
private $metadata;
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
...
->add('metadata', 'metadata')
...
;
}
$builder
...
->add('metadata', 'metadata', array(
'fields' => array(
'firstName' => array('text'),
'lastName' => array('text'),
'address' => array('text'),
'city' => array('text'),
'country' => array('text'),
'message' => array('textarea')
)
))
...
;
$builder
...
->add('features', 'related_to_many_metadata_features')
->add('tags', 'related_to_many_metadata_tags')
...
;
sh
php composer update