public function buildForm(AdminInterface $admin, FormMapper $formMapper) { /** * Bind data to the mapped fields */ $formMapper->getFormBuilder()->addEventListener(FormEvents::POST_SET_DATA, function (FormEvent $formEvent) { $data = $formEvent->getData(); $form = $formEvent->getForm(); if ($data instanceof Route) { $form->get('source')->setData($data->getPath()); $form->get('target')->setData($data->getDefault('path')); } }); /** * Bind the mapped fields to the entity */ $formMapper->getFormBuilder()->addEventListener(FormEvents::SUBMIT, function (FormEvent $formEvent) { $data = $formEvent->getData(); $form = $formEvent->getForm(); if ($data instanceof Route) { $data->setStaticPrefix($form->get('source')->getData()); $data->setDefault('path', $form->get('target')->getData()); $data->setDefault('_controller', $this->routeController); $data->setDefault('permanent', true); } }); $formMapper->add('source', 'text', ['mapped' => false]); $formMapper->add('target', 'text', ['mapped' => false]); $formMapper->remove('staticPrefix'); $formMapper->remove('variablePattern'); }
protected function configureFormFields(FormMapper $formMapper) { $subscriber = new AddMenuTypeFieldSubscriber($formMapper->getFormBuilder()->getFormFactory()); $formMapper->getFormBuilder()->addEventSubscriber($subscriber); // Getting the container parameters set in the config file that exist $menuSettings = $this->getConfigurationPool()->getContainer()->getParameter('menu_settings'); // Setting up the available actions $actionsChoice = $menuSettings['actions']; reset($actionsChoice); $prefActionsChoice = key($actionsChoice); // Setting up the available menu types $menuTypeChoice = $menuSettings['menutypes']; reset($menuTypeChoice); $prefMenuTypeChoice = key($menuTypeChoice); // Setting up the available menu groups $menuGroupsChoice = $menuSettings['menugroups']; reset($menuGroupsChoice); $prefMenuGroupsChoice = key($menuGroupsChoice); // Setting up the available page types and preffered choice $accessLevelChoices = $menuSettings['accessLevel']; reset($accessLevelChoices); $prefAccessLevelChoices = key($accessLevelChoices); // Setting up the available publish states and preffered choice $publishStateChoices = $menuSettings['publishState']; reset($publishStateChoices); $prefPublishStateChoices = key($publishStateChoices); $menus = $this->getConfigurationPool()->getContainer()->get('doctrine.orm.entity_manager')->getRepository('MenuBundle:Menu')->findAll(); $menusChoice['-'] = 'Hide From Menu'; $menusChoice['0'] = 'Menu Root'; foreach ($menus as $menu) { $menusChoice[$menu->getId()] = $menu->getTitle() . ' (' . $menu->getMenuGroup() . ')'; } $formMapper->tab('Menu Item Essential Details')->with('Menu Item Essential Details', array('collapsed' => true))->add('title', null, array('label' => 'Title', 'required' => true))->add('menuType', 'choice', array('choices' => $menuTypeChoice, 'preferred_choices' => array($prefMenuTypeChoice), 'label' => 'Menu Item Type', 'required' => true))->add('route', 'choice', array('choices' => $actionsChoice, 'preferred_choices' => array($prefActionsChoice), 'label' => 'Link Action', 'required' => true))->setHelps(array('title' => 'Set the title of the menu item (link copy text)', 'menuType' => 'Set the type of the menu item linked page', 'route' => 'Select the action of the menu item'))->end()->end()->tab('Menu Item Taxonomy')->with('Menu Item Taxonomy', array('collapsed' => true))->add('menuGroup', 'choice', array('choices' => $menuGroupsChoice, 'preferred_choices' => array($prefMenuGroupsChoice), 'label' => 'Menu Group', 'required' => true))->add('parent', 'choice', array('choices' => $menusChoice, 'attr' => array('class' => 'autoCompleteItems autoCompleteMenus', 'data-sonata-select2' => 'false'), 'label' => 'Parent Menu Item', 'required' => false))->add('ordering', null, array('label' => 'Menu Item Order', 'required' => true))->setHelps(array('menuGroup' => 'Set the menu group this menu item belongs to', 'parent' => 'Select the parent menu item', 'ordering' => 'Set the order of the menu item in accordance to the other menu items of the same menu level'))->end()->end()->tab('Menu Item Access Control')->with('Menu Item Access Control', array('collapsed' => true))->add('accessLevel', 'choice', array('choices' => $accessLevelChoices, 'preferred_choices' => array($prefAccessLevelChoices), 'label' => 'Access Level', 'required' => true))->add('publishState', 'choice', array('choices' => $publishStateChoices, 'preferred_choices' => array($prefPublishStateChoices), 'label' => 'Publish State', 'required' => true))->setHelps(array('accessLevel' => 'Set the minimum access level the item is visible to', 'publishState' => 'Set the publish state of this menu item'))->end()->end()->tab('Menu Item Optional Details')->with('Menu Item Optional Details', array('collapsed' => true))->add('menuImage', 'sonata_media_type', array('provider' => 'sonata.media.provider.image', 'context' => 'icons', 'attr' => array('class' => 'imagefield'), 'label' => 'Menu Icon Image', 'required' => false))->setHelps(array('menuImage' => 'Set an image as Menu Icon'))->end(); }
protected function configureFormFields(FormMapper $formMapper) { $subscriber = new AddCommentTypeFieldSubscriber($formMapper->getFormBuilder()->getFormFactory()); $formMapper->getFormBuilder()->addEventSubscriber($subscriber); // Getting the container parameters set in the config file that exist $commentSettings = $this->getConfigurationPool()->getContainer()->getParameter('comment_settings'); // Setting up the available comment types $commentTypeChoice = $commentSettings['commenttypes']; reset($commentTypeChoice); $prefCommentTypeChoice = key($commentTypeChoice); $formMapper->with('Comment Details', array('collapsed' => false))->add('title', null, array('label' => 'Comment Title', 'required' => true))->add('username', null, array('label' => 'Username / Name of the commentator', 'required' => true))->add('comment', 'textarea', array('label' => 'Comment', 'required' => true))->add('approved', 'choice', array('choices' => array('0' => 'Hide', '1' => 'Show'), 'preferred_choices' => array('1'), 'label' => 'Approve Comment', 'required' => true))->add('created', 'date', array('widget' => 'single_text', 'format' => 'dd-MM-yyyy', 'attr' => array('class' => 'datepicker'), 'label' => 'Created Date', 'required' => true))->add('commentType', 'choice', array('choices' => $commentTypeChoice, 'preferred_choices' => array($prefCommentTypeChoice), 'label' => 'Comment Type', 'required' => true))->setHelps(array('title' => 'Set the title of the comment', 'commentType' => 'Set the page type that this applies to', 'username' => 'Set username/name of the userer that commented', 'created' => 'The comment creation date', 'comment' => 'The contents of the comment', 'approved' => 'Aproval Status'))->end(); }
/** * {@inheritdoc} */ protected function configureFormFields(FormMapper $formMapper) { if ($this->getSubject()) { $classType = $this->getSubject()->getClassType(); } else { $classType = $this->getRequest()->get('classType'); } /** @var LayoutBlockFormListener $listener */ $listener = $this->getContainer()->get('networking_init_cms.layout_block_form_listener'); $listener->setAdmin($this); $listener->setContentType($classType); $formMapper->getFormBuilder()->addEventSubscriber($listener); $pageManager = $this->getContainer()->get('networking_init_cms.page_manager'); $transformer = new PageToNumberTransformer($pageManager); $formMapper->add('name', 'text')->add('zone', 'hidden')->add($formMapper->getFormBuilder()->create('page', 'hidden')->addModelTransformer($transformer), 'hidden')->add('classType', 'hidden')->add('sortOrder', 'hidden'); }
/** * @param FormMapper $formMapper */ protected function configureFormFields(FormMapper $formMapper) { $emIndustry = $this->modelManager->getEntityManager('Application\\AlexL\\Sonata\\ResumeBundle\\Entity\\Industry'); $query = $emIndustry->getRepository('AlexLSonataResumeBundle:Industry')->getFindAllParentsQueryBuilder(); $formMapper->add('company')->add('industry', 'sonata_type_model', ['attr' => ['onchange' => 'submit()'], 'query' => $query, 'required' => false])->add('subIndustry', 'sonata_type_model', ['choices' => [], 'required' => false])->add('workforce', 'sonata_type_model', ['required' => false])->add('jobTitle')->add('department', 'sonata_type_model', ['required' => false])->add('status', 'sonata_type_model', ['required' => false])->add('start', 'date', ['empty_value' => ['year' => 'Year', 'month' => 'Month', 'day' => 'Day']])->add('end', 'date', ['empty_value' => ['year' => 'Year', 'month' => 'Month', 'day' => 'Day']])->add('stillWork', null, ['label' => 'I still work there', 'required' => false])->add('description', 'ckeditor', ['help' => 'List you duties and responsibilities', 'required' => false])->add('managedTeam', null, ['label' => ' I managed a team', 'required' => false])->add('enabled', null, ['required' => false]); $builder = $formMapper->getFormBuilder(); $factory = $builder->getFormFactory(); $subject = $this->getSubject(); $modelManager = $this->getModelManager(); $formModifier = function (FormInterface $form, Industry $industry) use($emIndustry, $factory, $modelManager) { $query = $emIndustry->getRepository('AlexLSonataResumeBundle:Industry')->getFindChildrenByParentQueryBuilder($industry); $form->add($factory->createNamed('subIndustry', 'sonata_type_model', null, ['class' => 'Application\\AlexL\\Sonata\\ResumeBundle\\Entity\\Industry', 'query' => $query, 'required' => false, 'model_manager' => $modelManager, 'auto_initialize' => false])); }; $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($formModifier, $subject) { $form = $event->getForm(); if (!is_null($subject->getIndustry())) { $formModifier($form, $subject->getIndustry()); } }); $builder->get('industry')->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) use($formModifier, $subject) { $form = $event->getForm(); if (!is_null($subject->getIndustry())) { $formModifier($form, $subject->getIndustry()); } }); }
/** * @param FormMapper $formMapper */ protected function configureFormFields(FormMapper $formMapper) { $nested = is_numeric($formMapper->getFormBuilder()->getForm()->getName()); $formMapper->add('productCode')->add('price')->add('quantity')->add('product'); if (!$nested) { $formMapper->add('itemorder')->add('description'); } }
protected function configureFormFields(FormMapper $formMapper) { $formMapper->with("Рассказ"); if ($this->getSubject()->getId()) { $formMapper->add('storyOrder', 'number', ['label' => "Порядок отображения"]); } $formMapper->add("publicationDate", "sonata_type_date_picker", ['label' => "Дата публикации", 'format' => 'dd-MM-yyyy'])->add("title", "text", ["label" => "Название рассказа"])->add('text', 'sonata_formatter_type', ['label' => "Содержание рассказа", 'required' => TRUE, 'event_dispatcher' => $formMapper->getFormBuilder()->getEventDispatcher(), 'format_field' => 'textFormatter', 'source_field' => 'rawText', 'ckeditor_context' => 'base_config', 'listener' => TRUE, 'target_field' => 'text'])->add('storyCategory', 'entity', ['class' => 'AppBundle\\Entity\\StoryCategory', 'label' => "Категория рассказа"])->add("views", "number", ['required' => FALSE, "label" => "Просмотры"])->add('isFreeForAll', 'checkbox', ['required' => FALSE, 'label' => "Доступен для всех"])->end()->with("Локализации")->add("translations", "a2lix_translations_gedmo", ["label" => "Управление локализациями", "translatable_class" => 'AppBundle\\Entity\\Story', "required" => FALSE, "fields" => ["title" => ["locale_options" => ["en" => ["label" => "Story title"]]], "text" => ["locale_options" => ["en" => ["label" => "Content", 'field_type' => 'ckeditor', 'config_name' => 'base_config']]]]])->end()->with("Рецензии")->add("reviews", "sonata_type_collection", ['required' => FALSE, 'by_reference' => FALSE], ['multiple' => TRUE, 'edit' => 'inline', 'inline' => 'table']); }
/** * @param FormMapper $formMapper */ protected function configureFormFields(FormMapper $formMapper) { $nested = is_numeric($formMapper->getFormBuilder()->getForm()->getName()); $formMapper->add('name'); if (!$nested) { $formMapper->add('description')->add('isMain'); } $formMapper->add('value')->add('itemorder')->add('dictionaries', 'sonata_type_collection', array('label' => 'Dictionaries', 'required' => false, 'by_reference' => false), array('edit' => 'inline', 'inline' => 'table')); }
protected function configureFormFields(FormMapper $formMapper) { // Getting the container parameters set in the config file that exist $contentblockSettings = $this->getConfigurationPool()->getContainer()->getParameter('contentblock_settings'); // Setting up the available content types and preffered choice $contentTypeChoices = $contentblockSettings['contenttypes']; reset($contentTypeChoices); $prefContentTypeChoice = key($contentTypeChoices); // Setting up the available content sizes and preffered choice $sizeclassChoices = $contentblockSettings['contentsizes']; reset($sizeclassChoices); $prefSizeclassChoice = key($sizeclassChoices); // Setting up the available media sizes $mediasizes = $contentblockSettings['mediasizes']; $subscriber = new AddContentTypeFieldSubscriber($formMapper->getFormBuilder()->getFormFactory(), $mediasizes); $formMapper->getFormBuilder()->addEventSubscriber($subscriber); $formMapper->with('Content Block Details', array('collapsed' => false))->add('title', 'text', array('label' => 'Content Block Title', 'required' => true))->add('availability', 'choice', array('choices' => array('page' => 'One Page Only', 'global' => 'All Pages'), 'preferred_choices' => array('0'), 'label' => 'Available to', 'required' => true))->add('publishedState', 'choice', array('choices' => array('0' => 'Unpublished', '1' => 'Published'), 'preferred_choices' => array('1'), 'label' => 'Publish State', 'required' => true))->add('showTitle', 'choice', array('choices' => array('0' => 'Hide Title', '1' => 'Show Title'), 'preferred_choices' => array('1'), 'label' => 'Title Display State', 'required' => true))->add('ordering', 'hidden', array('attr' => array('class' => 'orderField'), 'label' => 'Content Block Ordering', 'required' => true))->add('className', 'text', array('label' => 'CSS Class', 'required' => false))->add('idName', 'text', array('label' => 'CSS Id', 'required' => false))->add('sizeclass', 'choice', array('choices' => $sizeclassChoices, 'preferred_choices' => array($prefSizeclassChoice), 'label' => 'Content Block Width', 'required' => true))->add('contentType', 'choice', array('choices' => $contentTypeChoices, 'preferred_choices' => array($prefContentTypeChoice), 'label' => 'Content Type', 'required' => true))->setHelps(array('title' => 'Set the title of the content block'))->end(); }
/** * {@inheritdoc} */ protected function configureFormFields(FormMapper $formMapper) { /* d('$formMapper'); d('$formMapper'); d($formMapper); */ $formMapper->with('Work', array('class' => 'col-md-8'))->add('author', 'sonata_type_model_list')->add('title')->add('slug', null, array('required' => true))->add('link', 'url', array('required' => false))->add('abstract', null, array('attr' => array('rows' => 5)))->add('content', 'sonata_formatter_type', array('event_dispatcher' => $formMapper->getFormBuilder()->getEventDispatcher(), 'format_field' => 'contentFormatter', 'source_field' => 'rawContent', 'source_field_options' => array('horizontal_input_wrapper_class' => $this->getConfigurationPool()->getOption('form_type') == 'horizontal' ? 'col-lg-12' : '', 'attr' => array('class' => $this->getConfigurationPool()->getOption('form_type') == 'horizontal' ? 'span10 col-sm-10 col-md-10' : '', 'rows' => 20)), 'ckeditor_context' => 'portfolio', 'target_field' => 'content', 'listener' => true))->end()->with('Status', array('class' => 'col-md-4'))->add('enabled', null, array('required' => false))->add('image', 'sonata_type_model_list', array('required' => false), array('link_parameters' => array('context' => 'portfolio')))->add('gallery', 'sonata_type_model_list', array('required' => false), array('link_parameters' => array('context' => 'portfolio')))->add('publicationDateStart', 'sonata_type_datetime_picker', array('dp_side_by_side' => true))->end()->with('Classification', array('class' => 'col-md-4'))->add('tags', 'sonata_type_model_autocomplete', array('property' => 'name', 'multiple' => 'true', 'required' => false))->add('collection', 'sonata_type_model_list', array('required' => false))->end(); }
protected function configureFormFields(FormMapper $formMapper) { $formMapper->add('title')->add('description')->add('tokens', 'text', array('label' => 'Class Tokens', 'required' => false))->add('scheduleColor', 'tsk_class_schedule_color_type'); // This subscriber is responsible for dynamically adding // the classTypeCredits interface $entityManager = $this->modelManager->getEntityManager('TSK\\ClassBundle\\Entity\\ClassType'); $builder = $formMapper->getFormBuilder(); $subscriber = new DrawClassTypeCredits($builder->getFormFactory(), $entityManager, $this->request->getSession()->get($this->orgSessionKey)); $builder->addEventSubscriber($subscriber); }
protected function configureFormFields(FormMapper $formMapper) { //$conf=new CMSConfiguration(); //$conf=$this->container->get('cms_conf'); $nested = is_numeric($formMapper->getFormBuilder()->getForm()->getName()); $formMapper->add('name')->add('itemorder', 'text', array('label' => 'Item Order'))->add('anchor', 'text', array('label' => 'Anchor'))->add('title', 'text', array('label' => 'Page Title'))->add('description', 'text', array('label' => 'Page Description'))->add('keywords', 'text', array('label' => 'Page Keywords'))->add('type', 'choice', array('multiple' => false, 'choices' => $this->conf->getKeys('page_types'))); if (!$nested) { $formMapper->add('media', 'sonata_type_model_list', array('required' => false), array())->add('site')->add('page')->add('href', 'text', array('label' => 'Href', 'required' => false))->add('isMenu')->add('priority')->add('isActive')->add('articles', 'sonata_type_collection', array('label' => 'Articles', 'required' => false, 'by_reference' => false), array('edit' => 'inline', 'inline' => 'standard'))->add('pages', 'sonata_type_collection', array('label' => 'Pages', 'required' => false, 'by_reference' => false), array('edit' => 'inline', 'inline' => 'table'))->add('pageSections', 'sonata_type_collection', array('label' => 'Sekcje', 'required' => false, 'by_reference' => false), array('edit' => 'inline', 'inline' => 'table'))->add('language')->add('contents', 'sonata_type_collection', array('label' => 'Wersje językowe', 'required' => false, 'by_reference' => false), array('edit' => 'inline', 'inline' => 'standard')); } }
/** * Закончить задание содержания мультиязычной * вкладки и передать результат в мапер формы * @desc Метод повторяет поведение класса FormMapper * @return FormMapper */ public function end() { $eventSubscriber = new AddTranslationFieldSubscriber($this->em, $this->localeManager, $this->mappingFactory, $this->fileStorage); $this->formMapper->getFormBuilder()->addEventSubscriber($eventSubscriber); $firstTab = true; $locales = $this->localeManager->getActiveList(); $administrator = $this->getTokenStorage()->getToken()->getUser(); if ($administrator instanceof Administrator) { usort($locales, [$administrator, 'sortLocales']); } foreach ($locales as $localeData) { $tabName = $localeData->getName(); if (strlen($this->tabName) > 0) { $tabName = str_replace('%locale_name%', $localeData->getName(), $this->tabName); } $tabOptions = []; if ($this->isDisabledByAdministratorLocales($localeData->getAlias())) { $tabOptions = ['class' => 'disabled']; } $this->formMapper->with($tabName, $tabOptions); foreach ($this->fields as $fieldData) { if (!$firstTab && (!isset($fieldData['options']['translatable']) || !$fieldData['options']['translatable'])) { continue; } $fieldName = $fieldData['name']; if (isset($fieldData['options']['translatable'])) { if ($fieldData['options']['translatable']) { $fieldName = 'translation___' . $fieldData['name'] . '___' . $localeData->getAlias(); $fieldData['options']['mapped'] = false; if (isset($fieldData['options']['locale'])) { $fieldData['options']['locale'] = $localeData->getAlias(); } $fieldData['options']['disabled'] = $this->isDisabled($localeData->getAlias(), $fieldData['options']); if ($localeData->getAlias() != $this->localeManager->getDefaultLocaleAlias()) { //убираем обязательность полей для языков $fieldData['options']['required'] = false; if (!empty($fieldData['options']['inner_constraints'])) { foreach ($fieldData['options']['inner_constraints'] as $key => $value) { if ($value instanceof FileNotBlank) { unset($fieldData['options']['inner_constraints'][$key]); } } } } } unset($fieldData['options']['translatable']); } $this->formMapper->add($fieldName, $fieldData['type'], $fieldData['options'], $fieldData['fieldDescriptionOptions']); } $this->formMapper->end(); $firstTab = false; } return $this->formMapper; }
/** * @param FormMapper $formMapper */ protected function configureFormFields(FormMapper $formMapper) { $formMapper->add('product', null, array('read_only' => true, 'disabled' => true))->add('process', null, array('read_only' => true, 'disabled' => true))->add('employee', null, array('read_only' => true, 'disabled' => true))->add('startDateTime', 'sonata_type_datetime_picker', array('required' => false, 'format' => 'dd/MM/yyyy HH:mm'))->add('endDateTime', 'sonata_type_datetime_picker', array('required' => false, 'format' => 'dd/MM/yyyy HH:mm'))->add('timeConsuming', null, array('required' => false, 'label' => 'Total time spent (minutes)', 'disabled' => true))->add('finishedFlag', 'choice', array('choices' => array(0 => 'No', 1 => 'Yes'), 'expanded' => true, 'multiple' => false, 'required' => true, 'label' => 'Finished?')); $formMapper->getFormBuilder()->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { $object = $this->getSubject($event->getData()); $form = $event->getForm(); if (!$object || null === $object->getId()) { $form->add('product', null, array('required' => true, 'disabled' => false, 'empty_value' => '----choose product----'))->add('process', null, array('required' => true, 'disabled' => false, 'empty_value' => '----choose process----'))->add('employee', null, array('required' => true, 'disabled' => false, 'empty_value' => '----choose employee----')); } }); }
protected function configureFormFields(FormMapper $formMapper) { $nested = is_numeric($formMapper->getFormBuilder()->getForm()->getName()); if (!$nested) { $formMapper->add('category', 'entity', array('class' => 'Softlogo\\ShopBundle\\Entity\\Category', 'label' => 'Kategoria')); } $formMapper->add('name', 'text', array('label' => 'Nazwa podkategorii')); //->add('description', 'ckeditor', array('label' => 'Opis podkategorii')) if (!$nested) { $formMapper->with('Produkty', array('collapsed' => true))->add('products', 'sonata_type_collection', array('label' => 'Produkty', 'by_reference' => false, 'required' => false, 'type_options' => array('delete' => true)), array('edit' => 'inline', 'inline' => 'standard', 'allow_delete' => true)); } }
protected function configureFormFields(FormMapper $formMapper) { if ($this->hasRequest()) { $link_parameters = array('context' => $this->getRequest()->get('context')); } else { $link_parameters = array(); } $nested = is_numeric($formMapper->getFormBuilder()->getForm()->getName()); $formMapper->with('Section')->add('title', 'text', array('label' => 'Title'))->add('itemorder', 'text', array('label' => 'Item Order'))->add('type', 'choice', array('multiple' => false, 'choices' => $this->conf->getKeys('section_types')))->end(); if (!$nested) { $formMapper->with('Media')->add('sectionMedias', 'sonata_type_collection', array('label' => 'Media', 'required' => false, 'by_reference' => false), array('edit' => 'inline', 'inline' => 'table'))->end()->add('articles', 'sonata_type_collection', array('label' => 'Articles', 'required' => false, 'by_reference' => false), array('edit' => 'inline', 'inline' => 'standard'))->add('contents', 'sonata_type_collection', array('label' => 'Wersje językowe', 'required' => false, 'by_reference' => false), array('edit' => 'inline', 'inline' => 'standard'))->end()->with('Sekcje')->add('sectionSections', 'sonata_type_collection', array('label' => 'Sekcje', 'required' => false, 'by_reference' => false), array('edit' => 'inline', 'inline' => 'table'))->end()->add('sectionParameters', 'sonata_type_collection', array('label' => 'Parameters', 'required' => false, 'by_reference' => false), array('edit' => 'inline', 'inline' => 'table'))->end(); } }
protected function configureFormFields(FormMapper $formMapper) { $locales = $this->container->getParameter('ao_translation.locales'); $formMapper->add('translations', new TranslationsType($this->getSubject(), $locales), array('required' => false, 'mapped' => false)); $formMapper->getFormBuilder()->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) { $form = $event->getForm(); $message = $form->getData(); $data = $event->getData(); foreach ($data['translations'] as $locale => $translation) { $message->setTranslation($locale, $translation); } }); }
/** * {@inheritdoc} */ protected function configureFormFields(FormMapper $formMapper) { $formMapper->with('Option', array('class' => 'col-md-8'))->add('url', 'url')->add('processed')->add('hasError')->add('skip')->add('crawledAt')->add('notes')->end(); $formMapper->getFormBuilder()->get('notes')->addModelTransformer(new CallbackTransformer(function ($dbNotes) { $json = json_encode($dbNotes); return $json; }, function ($formNotes) { if (empty($formNotes)) { return []; } $array = json_decode($formNotes, true); return $array; })); }
protected function configureFormFields(FormMapper $formMapper) { $route = $this->getRequest()->attributes->get("_route"); if ($route == "admin_app_chapter_edit" || $route == "admin_app_chapter_create") { $bookTitle = $this->getSubject()->getBook() ? $this->getSubject()->getBook()->getTitle() : NULL; $formMapper->with("Глава книги \"{$bookTitle}\"")->add("chapterOrder", "number", ["label" => "Номер главы"])->add("title", "text", ["label" => "Название главы"])->add('text', 'sonata_formatter_type', ['label' => "Содержание главы", 'required' => FALSE, 'event_dispatcher' => $formMapper->getFormBuilder()->getEventDispatcher(), 'format_field' => 'textFormatter', 'source_field' => 'rawText', 'ckeditor_context' => 'base_config', 'listener' => TRUE, 'target_field' => 'text'])->end()->with("Локализации")->add("translations", "a2lix_translations_gedmo", ["label" => "Управление локализациями", "translatable_class" => 'AppBundle\\Entity\\Chapter', "required" => FALSE, "fields" => ["title" => ["locale_options" => ["en" => ["label" => "Chapter title"]]], "text" => ["locale_options" => ["en" => ["label" => "Content", 'field_type' => 'ckeditor', 'config_name' => 'base_config']]]]]); } else { if ($this->getSubject() && $this->getSubject()->getId()) { $formMapper->add("chapterOrder", "number", ["label" => "Номер главы"])->add("title", "text", ["label" => "Название главы"])->add("link", "link_field", ['mapped' => FALSE, 'data' => $this->getSubject()->getId()]); } else { $formMapper->add("chapterOrder", "number", ["label" => "Номер главы", "read_only" => TRUE])->add("title", "text", ["label" => "Название главы"]); } } }
public function buildForm(AdminInterface $admin, FormMapper $formMapper) { /** * Bind the mapped fields to the entity */ $formMapper->getFormBuilder()->addEventListener(FormEvents::SUBMIT, function (FormEvent $formEvent) { $data = $formEvent->getData(); $form = $formEvent->getForm(); if ($data instanceof Route) { $data->setDefault('_controller', $this->routeController); $data->setDefault('permanent', true); $data->setDefault('path', ''); } }); }
public function configureFormFields(FormMapper $formMapper) { $media = $formMapper->getFormBuilder()->getData(); if(!$media->getProviderName()) { return; } $provider = $this->pool->getProvider($media->getProviderName()); if ($media->getId() > 0) { $provider->buildEditForm($formMapper); } else { $provider->buildCreateForm($formMapper); } }
/** * {@inheritdoc} */ protected function configureFormFields(FormMapper $formMapper) { $media = $this->getSubject(); if (!$media) { $media = $this->getNewInstance(); } if (!$media || !$media->getProviderName()) { return; } $formMapper->getFormBuilder()->addModelTransformer(new ProviderDataTransformer($this->pool, $this->getClass()), true); $provider = $this->pool->getProvider($media->getProviderName()); if ($media->getId()) { $provider->buildEditForm($formMapper); } else { $provider->buildCreateForm($formMapper); } }
protected function configureFormFields(FormMapper $formMapper) { $em = $this->getModelManager()->getEntityManager($this->getSubject()); $searchTagsTransformer = new SearchTagsToStringTransformer($em); $filearray = $this->getRoot()->getSubject()->getImageFile(); if (isset($filearray['fileName'])) { if (file_exists("./upload/publication/cropped" . $this->getRoot()->getSubject()->getImageFile()['fileName'])) { $filename = "/upload/publication/cropped" . $this->getRoot()->getSubject()->getImageFile()['fileName']; } elseif (file_exists("./upload/publication" . $this->getRoot()->getSubject()->getImageFile()['fileName'])) { $filename = "/upload/publication" . $this->getRoot()->getSubject()->getImageFile()['fileName']; } else { $filename = "/holder.js/180x150"; } } else { $filename = "/holder.js/180x150"; } $formMapper->add('title', 'textarea', array('label' => 'Название'))->add('shortText', null, array('required' => false, 'label' => 'Анонс *', 'attr' => array('class' => 'ckeditortrial')))->add('body', null, array('required' => false, 'label' => 'Текст *', 'attr' => array('class' => 'tinymce')))->add('embeddedCode', null, array('required' => false, 'label' => 'HTML-код видео'))->add('attachments', 'sonata_type_collection', array('required' => false, 'label' => 'Приложенные файлы', 'by_reference' => false), array('edit' => 'inline', 'inline' => 'table'))->add('category', null, array('label' => 'Категория'))->add('sourceTitle', null, array('label' => 'Название источника'))->add('sourceUrl', null, array('label' => 'Ссылка на источник'))->add('country', null, array('label' => 'Страна'))->add('imageFile', 'comur_image', array('uploadConfig' => array('uploadRoute' => 'comur_api_upload', 'uploadUrl' => $this->getRoot()->getSubject()->getUploadRootDir(), 'webDir' => $this->getRoot()->getSubject()->getUploadDir(), 'fileExt' => '*.jpg;*.gif;*.png;*.jpeg', 'libraryDir' => null, 'libraryRoute' => 'comur_api_image_library', 'showLibrary' => false, 'saveOriginal' => 'originalImage', 'imageFile' => $filename), 'cropConfig' => array('minWidth' => 450, 'minHeight' => 300, 'aspectRatio' => true, 'cropRoute' => 'comur_api_crop', 'forceResize' => false, 'thumbs' => array(array('maxWidth' => 450, 'maxHeight' => 300, 'useAsFieldImage' => true))), 'required' => false, 'label' => 'Изображение', 'data' => $this->getRoot()->getSubject()->getImageFile()))->add('hideAuthor', null, array('label' => 'Скрывать автора', 'help' => 'С галочкой вместо автора будет Evrika.ru', 'required' => false))->add('isVidal', null, array('label' => 'Публикация в Vidal', 'required' => false))->add('public', null, array('required' => false, 'label' => 'Могут видеть гости', 'help' => 'Если галочка не отмечена, то гости будут видеть только анонс'))->add('important', null, array('required' => false, 'label' => 'Отображать на главной', 'help' => 'Публикация попадёт на в главную ленту, но не будет закреплена в ней, если не указана дата закрепления (см. ниже)'))->add('stickedUntil', null, array('label' => 'Закреплена на главной до'))->add('thematicGroup', null, array('label' => 'Тематическая группа', 'help' => 'Если выбрана, то публикация будет опубликована внутри группы', 'query_builder' => function (ThematicGroupRepository $er) { return $er->createQueryBuilder('t')->orderBy('t.title', 'ASC'); }))->add('specialties', null, array('required' => false, 'label' => 'Специальности', 'help' => ''))->add('specializations', null, array('required' => false, 'label' => 'Специализация основной специальности', 'attr' => array('data-placeholder' => 'Выберите специализацию')))->add('poll', null, array('required' => false, 'label' => 'Установить опрос', 'empty_value' => 'без опроса'))->add('broadcast', null, array('required' => false, 'label' => 'Для всех специальностей', 'help' => 'Если да - публикация попадёт в ленту даже тем, кто не подписан на эти специальности'))->add('weekly', null, array('label' => 'Еженедельная', 'required' => false))->add('enabled', null, array('required' => false, 'label' => 'Активна'))->add('created', null, array('required' => false, 'label' => 'Дата создания'))->add('searchTags', null, array('required' => false, 'label' => 'Ключевые слова'))->add($formMapper->create('searchTags', 'text', array('label' => 'Ключевые слова', 'required' => false, 'by_reference' => false))->addModelTransformer($searchTagsTransformer))->add('metaTitle', null, array('label' => 'META title', 'required' => false))->add('keywords', null, array('label' => 'META keywords', 'required' => false))->add('description', null, array('label' => 'META description', 'required' => false))->add('yandexUniqueText', null, array('label' => 'META Yandex.Вебмастер оригинальный текст', 'required' => false, 'read_only' => true, 'disabled' => true))->add('digest', null, array('label' => 'В дайджесте', 'required' => false)); $builder = $formMapper->getFormBuilder(); // Add listeners // $builder->addEventListener(FormEvents::PRE_UPDATE, array($this, 'onPreSubmit')); /*$builder->addEventListener(FormEvents::PRE_BIND, function (FormEvent $event) use ($builder) { $data = $event->getData(); if (empty($data['imageFile'])) return; $selectedFoo = $data['imageFile']; $arrayImage = [ 'fileName' => $selectedFoo['imageFile'], 'originalName' => $selectedFoo['originalImage'], 'mimeType' => 'image/jpg', 'size' => 0, 'path' => '/upload/publication/'.$selectedFoo['imageFile'], 'width' => 200, 'height' => 200, ]; //$data['imageFile'] = serialize($arrayImage); //$data['originalImage'] = serialize($arrayImage); //$event->setData($data); //$setImage = "setImageFile"; //$setOImage = "setOriginalImage"; //$this->getRoot()->getSubject()->$setImage(serialize($arrayImage)); //$this->getRoot()->getSubject()->$setOImage(serialize($arrayImage)); });*/ }
/** * {@inheritdoc} */ protected function configureFormFields(FormMapper $formMapper) { $media = $this->getSubject(); if (!$media) { $media = $this->getNewInstance(); } if (!$media || !$media->getProviderName()) { return; } $formMapper->add('providerName', 'hidden'); $formMapper->getFormBuilder()->addModelTransformer(new ProviderDataTransformer($this->pool, $this->getClass()), true); $provider = $this->pool->getProvider($media->getProviderName()); if ($media->getId()) { $provider->buildEditForm($formMapper); } else { $provider->buildCreateForm($formMapper); } $formMapper->add('category', 'sonata_type_model_list', array(), array('link_parameters' => array('context' => $media->getContext(), 'hide_context' => true, 'mode' => 'tree'))); }
protected function configureFormFields(FormMapper $formMapper) { //$user = $this->securityContext->getToken()->getUser()->getUsername(); //$user = $this->securityContext->getToken()->getUser(); //die(var_dump($user)); // die(var_dump('toto est la')); $author = $this->securityContext->getToken()->getUser(); if ($this->isGranted('CREATE')) { $formMapper->add('author', 'sonata_type_model_hidden', array())->add('description', 'sizannia_editor_type', array('label' => 'Comments'))->add('isEnable', 'checkbox', array('required' => false, 'label' => 'Enable')); } $formMapper->getFormBuilder()->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use($author, $formMapper) { $event->setData($author); $comment = $event->getdata(); //$form = $event->getForm(); //$comment->setAuthor($author); //die(var_dump($comment)); $formMapper->create($comment, null, array()); // ->add('author', 'sonata_type_model_list') // ->add('description','sizannia_editor_type', array('label' => 'Comments')) // ->add('isEnable', 'checkbox', array('required' => false, 'label' => 'Enable')); }); }
/** * {@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)); }); }
protected function configureFormFields(FormMapper $formMapper) { $article = $this->getSubject(); $formMapper->with('General')->add('make', 'text', array('label' => 'Marke'))->add('manufacturer', 'text', array('label' => 'Hersteller'))->add('model', 'text', array('label' => 'Modell'))->add('description', 'sonata_formatter_type', array('label' => 'Beschreibung', 'event_dispatcher' => $formMapper->getFormBuilder()->getEventDispatcher(), 'format_field' => 'descriptionFormatter', 'source_field' => 'rawDescription', 'source_field_options' => array('attr' => array('class' => 'span10', 'rows' => 20)), 'target_field' => 'description', 'listener' => true, 'error_bubbling' => false))->add('price', 'integer', array('label' => 'Preis'))->add('weekPrice', 'integer', array('label' => 'Wochen-Preis'))->add('image', 'sonata_type_model', array('required' => true, 'multiple' => false))->add('images', 'sonata_type_model', array('required' => false, 'multiple' => true))->add('website', 'text', array('required' => false))->end(); if ($article instanceof Boxe) { $formMapper->with('Detail')->add('assembly', 'text', array('label' => 'Bestückung'))->add('kgWeight', 'integer', array('label' => 'Gewicht (kg)'))->add('frequency', 'text', array('label' => 'Frequenzbereich'))->add('dimensions', 'text', array('label' => 'Masse'))->end(); } if ($article instanceof Stand) { $formMapper->with('Detail')->add('maxHeight', 'text', array('label' => 'Maximale Höhe'))->add('minHeight', 'text', array('label' => 'Minimale Höhe'))->add('maxLoad', 'text', array('label' => 'Maximale Last'))->end(); } if ($article instanceof Cable) { $formMapper->with('Detail')->add('cmLength', 'integer', array('label' => 'Länge (cm.)'))->add('type', 'text', array('label' => 'Typ'))->end(); } if ($article instanceof Mixer) { $formMapper->with('Detail')->add('inputs', 'text', array('label' => 'Eingänge'))->add('outputs', 'text', array('label' => 'Ausgänge'))->add('preamps', 'text', array('label' => 'Vorverstärker'))->end(); } if ($article instanceof Mic) { $formMapper->with('Detail')->add('sensitivity', 'text', array('label' => 'Empfindlichkeit'))->add('directivity', 'text', array('label' => 'Richtcharakteristik'))->add('transmissionRange', 'text', array('label' => 'Übertragungsbereich'))->add('weight', 'text', array('label' => 'Gewicht'))->end(); } if ($article instanceof Player) { $formMapper->with('Detail')->add('supportedFormats', 'text', array('label' => 'Formate'))->add('outputs', 'text', array('label' => 'Ausgänge'))->end(); } }
protected function configureFormFields(FormMapper $formMapper) { $component = $this->getSubject(); $formMapper->with('General')->add('name', 'text', array('label' => 'Name'))->add('description', 'sonata_formatter_type', array('label' => 'Beschreibung', 'event_dispatcher' => $formMapper->getFormBuilder()->getEventDispatcher(), 'format_field' => 'descriptionFormatter', 'source_field' => 'rawDescription', 'source_field_options' => array('attr' => array('class' => 'span10', 'rows' => 20)), 'target_field' => 'description', 'listener' => true, 'error_bubbling' => false))->add('image', 'sonata_type_model', array('required' => true, 'multiple' => false))->add('possibleArticles', 'sonata_type_model', array('required' => false, 'multiple' => true)); }
/** * {@inheritdoc} */ protected function configureFormFields(FormMapper $formMapper) { $media = $this->getSubject(); if (!$media) { $media = $this->getNewInstance(); } if (!$media || !$media->getProviderName()) { return; } $formMapper->getFormBuilder()->addModelTransformer(new ProviderDataTransformer($this->pool, $this->getClass()), true); $provider = $this->pool->getProvider($media->getProviderName()); if ($media->getId()) { $provider->buildEditForm($formMapper); } else { $provider->buildCreateForm($formMapper); } if ($media->getId() && ($media->getProviderName() == 'sonata.media.provider.image' || $media->getProviderName() == 'sonata.media.provider.youtube')) { $formMapper->remove('binaryContent', 'file'); if ($media->getProviderName() == 'sonata.media.provider.youtube') { $formMapper->add('image', 'networking_type_mediaprint', array('required' => false, 'label' => 'form.label_current_video')); $formMapper->add('binaryContent', 'text', array('required' => false, 'label' => 'form.label_binary_content_youtube_new')); } else { $formMapper->add('image', 'networking_type_mediaprint', array('required' => false)); $formMapper->add('binaryContent', 'file', array('required' => false, 'label' => 'form.label_binary_content_new')); } // } if (in_array($media->getProviderName(), $this->localisedMediaProviders)) { $formMapper->add('locale', 'choice', array('choices' => $this->getLocaleChoices())); } if ($formMapper->has('enabled')) { $formMapper->add('enabled', null, array('required' => false), array('inline_block' => true)); } if ($formMapper->has('cdnIsFlushable')) { $formMapper->add('cdnIsFlushable', null, array('required' => false), array('inline_block' => true)); $formMapper->reorder(array('name', 'enabled', 'cdnIsFlushable')); } if ($this->getSubject() && $this->getSubject()->getId()) { $formMapper->add('tags', 'sonata_type_model', array('required' => false, 'expanded' => false, 'multiple' => true, 'help_label' => 'help.media_tag', 'taggable' => true, 'attr' => array('style' => "width:220px"))); } }
protected function configureFormFields(FormMapper $formMapper) { $formMapper->add('name', 'text', array('label' => 'Name'))->add('summary', 'text', array('label' => 'kurze Beschreibung'))->add('orderNumber')->add('description', 'sonata_formatter_type', array('label' => 'Beschreibung', 'event_dispatcher' => $formMapper->getFormBuilder()->getEventDispatcher(), 'format_field' => 'descriptionFormatter', 'source_field' => 'rawDescription', 'source_field_options' => array('attr' => array('class' => 'span10', 'rows' => 20)), 'target_field' => 'description', 'listener' => true, 'error_bubbling' => false))->add('weekPrice', 'integer', array('label' => 'Wochen-Preis'))->add('components', 'sonata_type_collection', array('required' => false, 'by_reference' => false, 'label' => 'Komponenten'), array('edit' => 'inline', 'inline' => 'table', 'allow_delete' => true))->add('previewImage', 'sonata_type_model', array('required' => true, 'multiple' => false))->add('images', 'sonata_type_model', array('required' => false, 'multiple' => true))->add('categories', 'sonata_type_model', array('required' => false, 'multiple' => true))->add('previewOnStart')->add('locales'); }