et
2014-11-28 09:30:50 UTC
Hello,
I would like to have a widget like sonata_type_collection, with this
widget, i have a row like this:
$formMapper->add('articles', 'sonata_type_collection', array(
'required' => true
,'by_reference' => false
,'label' => "AJOUTEZ DES ARTICLES :"
,'disabled' => $commande->estCommandeIssuDeDevis()
,'btn_add' => $commande->estCommandeIssuDeDevis() ? false : 'Ajouter un
article'
),
array(
'edit' => 'inline'
,'multiple' => true
,'expanded' => true
,'inline' => 'table'
,'allow_delete' => ! $commande->estCommandeIssuDeDevis()
,'admin_code' => 'sonata.admin.CommandeArticle'
)
);
child:
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('Description', null, array(
'attr' => array('style' => 'width: 95%;')
))
->add('Quantite')
->add('article_taille', null, array(
'attr' => array('style' => 'width: 95%;')
))
;
}
<Loading Image...
>
but i would like to have a line for each element of the select (already
selected)
I would like to modify this class, and use it normally:
- i replace 'sonata_type_collection' with 'mon_sonata_type_collection':
$formMapper->add('articles', 'mon_sonata_type_collection');
- add the inherited class into l3ia\Bundle\ERPBundle\Form\Type\
MonSonataCollectionType.php:
namespace l3ia\Bundle\ERPBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Sonata\CoreBundle\Form\EventListener\ResizeFormListener;
class MonSonataCollectionType extends AbstractType
{
/**
* {@inheritDoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$listener = new ResizeFormListener(
$options['type'],
$options['type_options'],
$options['modifiable'],
$options['pre_bind_data_callback']
);
$builder->addEventSubscriber($listener);
}
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form, array
$options)
{
$view->vars['btn_add'] = $options['btn_add'];
$view->vars['btn_catalogue'] = $options['btn_catalogue'];
}
/**
* {@inheritDoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'modifiable' => false,
'type' => 'text',
'type_options' => array(),
'pre_bind_data_callback' => null,
'btn_add' => 'link_add',
'btn_catalogue' => 'SonataCoreBundle'
));
}
/**
* {@inheritDoc}
*/
public function getName()
{
return 'mon_sonata_type_collection';
}
}
- add the service in file that there is other services that all works:
l3ia.form.type.mon_sonata_type_collection:
class: l3ia\Bundle\ERPBundle\Form\Type\MonSonataCollectionType
tag:
- { name: form.type, alias: mon_sonata_type_collection }
but i've got an error:
Could not load type "mon_sonata_type_collection"
must i do another thing ?
I would like to have a widget like sonata_type_collection, with this
widget, i have a row like this:
$formMapper->add('articles', 'sonata_type_collection', array(
'required' => true
,'by_reference' => false
,'label' => "AJOUTEZ DES ARTICLES :"
,'disabled' => $commande->estCommandeIssuDeDevis()
,'btn_add' => $commande->estCommandeIssuDeDevis() ? false : 'Ajouter un
article'
),
array(
'edit' => 'inline'
,'multiple' => true
,'expanded' => true
,'inline' => 'table'
,'allow_delete' => ! $commande->estCommandeIssuDeDevis()
,'admin_code' => 'sonata.admin.CommandeArticle'
)
);
child:
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('Description', null, array(
'attr' => array('style' => 'width: 95%;')
))
->add('Quantite')
->add('article_taille', null, array(
'attr' => array('style' => 'width: 95%;')
))
;
}
<Loading Image...
but i would like to have a line for each element of the select (already
selected)
I would like to modify this class, and use it normally:
- i replace 'sonata_type_collection' with 'mon_sonata_type_collection':
$formMapper->add('articles', 'mon_sonata_type_collection');
- add the inherited class into l3ia\Bundle\ERPBundle\Form\Type\
MonSonataCollectionType.php:
namespace l3ia\Bundle\ERPBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Sonata\CoreBundle\Form\EventListener\ResizeFormListener;
class MonSonataCollectionType extends AbstractType
{
/**
* {@inheritDoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$listener = new ResizeFormListener(
$options['type'],
$options['type_options'],
$options['modifiable'],
$options['pre_bind_data_callback']
);
$builder->addEventSubscriber($listener);
}
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form, array
$options)
{
$view->vars['btn_add'] = $options['btn_add'];
$view->vars['btn_catalogue'] = $options['btn_catalogue'];
}
/**
* {@inheritDoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'modifiable' => false,
'type' => 'text',
'type_options' => array(),
'pre_bind_data_callback' => null,
'btn_add' => 'link_add',
'btn_catalogue' => 'SonataCoreBundle'
));
}
/**
* {@inheritDoc}
*/
public function getName()
{
return 'mon_sonata_type_collection';
}
}
- add the service in file that there is other services that all works:
l3ia.form.type.mon_sonata_type_collection:
class: l3ia\Bundle\ERPBundle\Form\Type\MonSonataCollectionType
tag:
- { name: form.type, alias: mon_sonata_type_collection }
but i've got an error:
Could not load type "mon_sonata_type_collection"
must i do another thing ?
--
You received this message because you are subscribed to the Google Groups "sonata-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonata-users+***@googlegroups.com.
To post to this group, send email to sonata-***@googlegroups.com.
Visit this group at http://groups.google.com/group/sonata-users.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "sonata-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonata-users+***@googlegroups.com.
To post to this group, send email to sonata-***@googlegroups.com.
Visit this group at http://groups.google.com/group/sonata-users.
For more options, visit https://groups.google.com/d/optout.