/**
* @inheritDoc
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setRequired('manager');
$resolver->setAllowedTypes('manager', array(
ObjectManager::class
));
}
$form = $this->createForm(FooType::class, $object, array(
'manager' => $this->getDoctrine()->getManager(),
));
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->get('image')
->addModelTransformer(new EntityToNumberTransformer($options['manager'], 'AppBundle:File'));
}
app.type.foo:
class: %app.type.foo%
arguments:
- "@doctrine.orm.entity_manager"
tags:
- { name: form.type }
SiteController::breadcrubsAction
и вызывать его в шаблоне с помощью{{ render(controller('AppBundle:Site:breadcrubs')) }}
{{ breadcrumbs() }}
public function load(array $configs, ContainerBuilder $container)
{
$container->setDefinition('emailsender', new Definition('MailerBundle\Sender\EmailSender', [
new Reference('swiftmailer.mailer'),
new Reference('swiftmailer.transport')]));
$container->setDefinition('emailnotifier', new Definition('MailerBundle\Controller\EmailController', [
new Reference('emailsender')]));
}
$collection->setAlbums(
new ArrayCollection(
array_merge(
array($album),
$collection->getAlbums()->toArray()
)
)
);
public function loadUserByUsername($username)
{
// make a call to your webservice here
$userData = ...
// pretend it returns an array on success, false if there is no user
if ($userData) {
$password = '...';
// ...
return new WebserviceUser($username, $password, $salt, $roles);
}
// Тут создаем пользователя
}
Условие isSubmitted не выполняется при отправке формы.
$form->handleRequest($request);
ждет POST-запрос.$this->createForm(SelectedDeviceType::class, $data, array(
'method' => 'GET'
));
$this->createForm(SelectedDeviceType::class, $data, array(
'action' => $this->generateUrl('form_submit_route');
));