本文整理汇总了PHP中Sonata\AdminBundle\Form\FormMapper::getAdmin方法的典型用法代码示例。如果您正苦于以下问题:PHP FormMapper::getAdmin方法的具体用法?PHP FormMapper::getAdmin怎么用?PHP FormMapper::getAdmin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sonata\AdminBundle\Form\FormMapper
的用法示例。
在下文中一共展示了FormMapper::getAdmin方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: configureFormFields
protected function configureFormFields(FormMapper $form)
{
$subject = $form->getAdmin()->getSubject();
$form->add('translations', 'translatable_group', array('personal_translation' => 'Site\\BaseBundle\\Entity\\BlogTranslation', 'fields' => array('title', 'content'), 'widgets' => array('title' => 'text', 'content' => 'textarea'), 'field_options' => array('title' => array('label' => 'Title'), 'content' => array('label' => 'Content', 'attr' => array('class' => 'tinymce', 'data-theme' => 'simple')))));
if ($subject->getId()) {
$this->setTemplate('edit', 'SiteAdminBundle:BlogAdmin:edit.html.twig');
}
}
示例2: configureFormFields
protected function configureFormFields(FormMapper $form)
{
$subject = $form->getAdmin()->getSubject();
$form->add('accommodation')->add('iframe_code')->add('translations', 'translatable_group', array('personal_translation' => 'Site\\BaseBundle\\Entity\\AccommodationTranslation', 'fields' => array('title', 'program', 'additional'), 'widgets' => array('title' => 'text', 'program' => 'textarea', 'additional' => 'textarea'), 'field_options' => array('title' => array('label' => 'Title'), 'program' => array('label' => 'Program', 'attr' => array('class' => 'tinymce', 'data-theme' => 'medium')), 'additional' => array('label' => 'Additional', 'attr' => array('class' => 'tinymce', 'data-theme' => 'simple')))));
if ($subject->getId()) {
$this->setTemplate('edit', 'SiteAdminBundle:RouteAdmin:edit.html.twig');
}
}
示例3: configureFormFields
protected function configureFormFields(FormMapper $form)
{
$subject = $form->getAdmin()->getSubject();
$form->add('translations', 'translatable_group', array('personal_translation' => 'Site\\BaseBundle\\Entity\\AccommodationTranslation', 'fields' => array('title', 'description', 'secondary_text'), 'widgets' => array('title' => 'text', 'description' => 'textarea', 'secondary_text' => 'textarea'), 'field_options' => array('title' => array('label' => 'Title'), 'description' => array('label' => 'Description', 'attr' => array('class' => 'tinymce', 'data-theme' => 'simple')), 'secondary_text' => array('label' => 'Second text', 'attr' => array('class' => 'tinymce', 'data-theme' => 'medium')))))->add('file', 'image_delete', array('filter' => 'accommodation_admin_preview', 'required' => false))->add('show_on_homepage');
if ($subject->getId()) {
$this->setTemplate('edit', 'SiteAdminBundle:AccommodationAdmin:edit.html.twig');
}
}
示例4: getFormAdminType
/**
* @param FormMapper $formMapper
* @param AdminInterface $admin
* @param string $formField
* @param string $field
* @param array $fieldOptions
* @param array $adminOptions
*
* @return FormBuilder
*/
protected final function getFormAdminType(FormMapper $formMapper, AdminInterface $admin, $formField, $field, $fieldOptions = array(), $adminOptions = array())
{
$adminOptions = array_merge(array('edit' => 'list', 'translation_domain' => 'SonataClassificationBundle'), $adminOptions);
$fieldDescription = $admin->getModelManager()->getNewFieldDescriptionInstance($admin->getClass(), $field, $adminOptions);
$fieldDescription->setAssociationAdmin($admin);
$fieldDescription->setAdmin($formMapper->getAdmin());
$fieldDescription->setAssociationMapping(array('fieldName' => $field, 'type' => ClassMetadataInfo::MANY_TO_ONE));
$fieldOptions = array_merge(array('sonata_field_description' => $fieldDescription, 'class' => $admin->getClass(), 'model_manager' => $admin->getModelManager(), 'required' => false), $fieldOptions);
return $formMapper->create($formField, 'sonata_type_model_list', $fieldOptions);
}
示例5: getFieldFormBuilder
/**
* @param \Sonata\AdminBundle\Form\FormMapper $formMapper
*
* @return \Symfony\Component\Form\FormBuilder
*/
protected function getFieldFormBuilder(FormMapper $formMapper)
{
// simulate an association ...
$fieldDescription = $this->getFormBuilderAdmin()->getModelManager()->getNewFieldDescriptionInstance($this->formBuilderAdmin->getClass(), 'form_builder');
$fieldDescription->setAssociationAdmin($this->getFormBuilderAdmin());
$fieldDescription->setAdmin($formMapper->getAdmin());
$fieldDescription->setOption('edit', 'list');
$fieldDescription->setAssociationMapping(array('fieldName' => 'form_builder', 'type' => \Doctrine\ORM\Mapping\ClassMetadataInfo::MANY_TO_ONE));
return $formMapper->create('formBuilderId', 'sonata_type_model', array('sonata_field_description' => $fieldDescription, 'label' => 'Form Builder', 'class' => $this->getFormBuilderAdmin()->getClass(), 'model_manager' => $this->getFormBuilderAdmin()->getModelManager()));
}
示例6: buildEditForm
/**
* {@inheritdoc}
*/
public function buildEditForm(FormMapper $formMapper)
{
$subject = $formMapper->getAdmin()->getSubject();
$formMapper->add('name');
$formMapper->add('enabled', null, array('required' => false));
$formMapper->add('authorName');
$formMapper->add('cdnIsFlushable');
$formMapper->add('description');
$formMapper->add('copyright');
$formMapper->add('binaryContent', 'file', array('required' => false, 'file_path' => $this->generatePublicUrl($subject, 'admin')));
}
示例7: buildEditForm
public function buildEditForm(CmsManagerInterface $manager, FormMapper $formMapper, BlockInterface $block)
{
$contextChoices = array();
foreach ($this->getMediaPool()->getContexts() as $name => $context) {
$contextChoices[$name] = $name;
}
$media = $block->getSetting('mediaId');
$formatChoices = array();
if ($media instanceof MediaInterface) {
$formats = $this->getMediaPool()->getFormatNamesByContext($media->getContext());
foreach ($formats as $code => $format) {
$formatChoices[$code] = $code;
}
}
// simulate an association ...
$fieldDescription = $formMapper->getAdmin()->getModelManager()->getNewFieldDescriptionInstance($this->mediaAdmin->getClass(), 'media');
$fieldDescription->setAssociationAdmin($this->getMediaAdmin());
$fieldDescription->setAdmin($formMapper->getAdmin());
$fieldDescription->setOption('edit', 'list');
$fieldDescription->setAssociationMapping(array('fieldName' => 'media', 'type' => \Doctrine\ORM\Mapping\ClassMetadataInfo::MANY_TO_ONE));
$builder = $formMapper->create('mediaId', 'sonata_type_model', array('sonata_field_description' => $fieldDescription, 'class' => $this->getMediaAdmin()->getClass(), 'model_manager' => $this->getMediaAdmin()->getModelManager()));
$formMapper->add('settings', 'sonata_type_immutable_array', array('keys' => array(array('title', 'text', array('required' => false)), array('context', 'choice', array('required' => true, 'choices' => $contextChoices)), array('format', 'choice', array('required' => count($formatChoices) > 0, 'choices' => $formatChoices)), array($builder, null, array()))));
}
示例8: configureFormFields
/**
* {@inheritdoc}
*/
public function configureFormFields(FormMapper $form)
{
$admin = $form->getAdmin();
$formBuilder = $form->getFormBuilder();
// PHP 5.3 BC
$fieldName = $this->fieldName;
$formBuilder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($admin, $fieldName) {
$data = $event->getData();
$form = $event->getForm();
if (null === $data || $form->getParent()) {
return;
}
$modelManager = $admin->getModelManager();
if (!$modelManager instanceof LockInterface) {
return;
}
if (null === ($lockVersion = $modelManager->getLockVersion($data))) {
return;
}
$form->add($fieldName, 'hidden', array('mapped' => false, 'data' => $lockVersion));
});
}
示例9: configureFormFields
/**
* {@inheritdoc}
*/
public function configureFormFields(FormMapper $form)
{
$this->eventDispatcher->dispatch('sonata.admin.event.configure.form', new ConfigureEvent($form->getAdmin(), $form, ConfigureEvent::TYPE_FORM));
}
示例10: buildEditForm
/**
* {@inheritdoc}
*/
public function buildEditForm(FormMapper $formMapper, BlockInterface $block)
{
$formMapper->add('settings', 'sonata_type_immutable_array', array('keys' => array(array('title', 'text', array('required' => false)), array('current', 'checkbox', array('required' => false)), array('pageId', 'sonata_page_selector', array('model_manager' => $formMapper->getAdmin()->getModelManager(), 'class' => $formMapper->getAdmin()->getClass(), 'site' => $block->getPage()->getSite(), 'required' => false)), array('class', 'text', array('required' => false)))));
}
示例11: buildEditForm
/**
* {@inheritdoc}
*/
public function buildEditForm(FormMapper $formMapper, BlockInterface $block)
{
$contextChoices = array();
foreach ($this->getMediaPool()->getContexts() as $name => $context) {
$contextChoices[$name] = $name;
}
$gallery = $block->getSetting('galleryId');
$formatChoices = array();
if ($gallery instanceof GalleryInterface) {
$formats = $this->getMediaPool()->getFormatNamesByContext($gallery->getContext());
foreach ($formats as $code => $format) {
$formatChoices[$code] = $code;
}
}
// simulate an association ...
$fieldDescription = $this->getGalleryAdmin()->getModelManager()->getNewFieldDescriptionInstance($this->getGalleryAdmin()->getClass(), 'media', array('translation_domain' => 'SonataMediaBundle'));
$fieldDescription->setAssociationAdmin($this->getGalleryAdmin());
$fieldDescription->setAdmin($formMapper->getAdmin());
$fieldDescription->setOption('edit', 'list');
$fieldDescription->setAssociationMapping(array('fieldName' => 'gallery', 'type' => ClassMetadataInfo::MANY_TO_ONE));
$builder = $formMapper->create('galleryId', 'sonata_type_model_list', array('sonata_field_description' => $fieldDescription, 'class' => $this->getGalleryAdmin()->getClass(), 'model_manager' => $this->getGalleryAdmin()->getModelManager(), 'label' => 'form.label_gallery'));
$formMapper->add('settings', 'sonata_type_immutable_array', array('keys' => array(array('title', 'text', array('required' => false, 'label' => 'form.label_title')), array('context', 'choice', array('required' => true, 'choices' => $contextChoices, 'label' => 'form.label_context')), array('format', 'choice', array('required' => count($formatChoices) > 0, 'choices' => $formatChoices, 'label' => 'form.label_format')), array($builder, null, array()), array('pauseTime', 'number', array('label' => 'form.label_pause_time')), array('startPaused', 'checkbox', array('required' => false, 'label' => 'form.label_start_paused')), array('wrap', 'checkbox', array('required' => false, 'label' => 'form.label_wrap'))), 'translation_domain' => 'SonataMediaBundle'));
}
示例12: buildEditForm
/**
* @param \Sonata\PageBundle\CmsManager\CmsManagerInterface $manager
* @param \Sonata\AdminBundle\Form\FormMapper $formMapper
* @param \Sonata\PageBundle\Model\BlockInterface $block
* @return void
*/
public function buildEditForm(CmsManagerInterface $manager, FormMapper $formMapper, BlockInterface $block)
{
$formMapper->add('settings', 'sonata_type_immutable_array', array('keys' => array(array('title', 'text', array('required' => false)), array('current', 'checkbox', array('required' => false)), array('pageId', 'sonata_page_selector', array('model_manager' => $formMapper->getAdmin()->getModelManager(), 'class' => 'Application\\Sonata\\PageBundle\\Entity\\Page', 'required' => false)), array('class', 'text', array('required' => false)))));
}
示例13: getMediaBuilder
/**
* @param FormMapper $formMapper
*
* @return FormBuilder
*/
protected function getMediaBuilder(FormMapper $formMapper)
{
// simulate an association ...
$fieldDescription = $this->getMediaAdmin()->getModelManager()->getNewFieldDescriptionInstance($this->mediaAdmin->getClass(), 'media', array('translation_domain' => 'SonataMediaBundle'));
$fieldDescription->setAssociationAdmin($this->getMediaAdmin());
$fieldDescription->setAdmin($formMapper->getAdmin());
$fieldDescription->setOption('edit', 'list');
$fieldDescription->setAssociationMapping(array('fieldName' => 'media', 'type' => ClassMetadataInfo::MANY_TO_ONE));
return $formMapper->create('mediaId', 'sonata_type_model_list', array('sonata_field_description' => $fieldDescription, 'class' => $this->getMediaAdmin()->getClass(), 'model_manager' => $this->getMediaAdmin()->getModelManager(), 'label' => 'form.label_media'));
}
示例14: getBlockBuilder
/**
* @param FormMapper $formMapper
*
* @return FormBuilder
*/
protected function getBlockBuilder(FormMapper $formMapper)
{
// simulate an association ...
$fieldDescription = $this->getSharedBlockAdmin()->getModelManager()->getNewFieldDescriptionInstance($this->sharedBlockAdmin->getClass(), 'block', array('translation_domain' => 'SonataPageBundle'));
$fieldDescription->setAssociationAdmin($this->getSharedBlockAdmin());
$fieldDescription->setAdmin($formMapper->getAdmin());
$fieldDescription->setOption('edit', 'list');
$fieldDescription->setAssociationMapping(array('fieldName' => 'block', 'type' => \Doctrine\ORM\Mapping\ClassMetadataInfo::MANY_TO_ONE));
return $formMapper->create('blockId', 'sonata_type_model_list', array('sonata_field_description' => $fieldDescription, 'class' => $this->getSharedBlockAdmin()->getClass(), 'model_manager' => $this->getSharedBlockAdmin()->getModelManager(), 'label' => 'form.label_block', 'required' => false));
}