Closed meiome closed 9 years ago
use a different PriceListAdmin class in which you'll set the field article as hidden, you can specify which Admin class to use in your Article form with the option 'admin_code' in the second array like so :
$formMapper->add('pricelist', 'sonata_type_collection', array(), array( 'edit' => 'inline', 'inline' => 'table', 'sortable' => 'position', 'admin_code' => 'sonata.admin.price_list', ))
thankyou sfavot!!!!!
I find only this method ('sonata_type_collection') to insert a entity cascade one to many I want that the entity daughter does not require the selection of his father, but that this is taken directly help my please!!!!
//ArticleAdmin namespace Andrea\PrimoBundle\Admin;
use Sonata\AdminBundle\Admin\Admin; use Sonata\AdminBundle\Datagrid\ListMapper; use Sonata\AdminBundle\Datagrid\DatagridMapper; use Sonata\AdminBundle\Form\FormMapper;
class ArticleAdmin extends Admin { // Fields to be shown on create/edit forms protected function configureFormFields(FormMapper $formMapper) { $formMapper ->add('description', 'text', array('label' => 'Descrizione Articolo')) ->add('code', 'text', array('label' => 'Codice Articolo')) ->add('disable', 'checkbox', array('required' => false,'label' => 'Disabilitato')) //->add('taxcode', null, array('label' => 'Codice Iva')) ->add('taxcode', 'entity', array('class' => 'Andrea\PrimoBundle\Entity\TaxCode'))
class Article { /* * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") / protected $id;
//etc ........................................ }
class PriceList { /* * @var integer * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id;
//etc....
}