/** * Adds empty content in various languages to the category entity if necessary * Instantiates the forms and binds it to the data * @param Category $category * @param null &$form Referenced * @param bool $isNew * @return bool|JsonModel */ protected function prepareFormAndLanguage($category, &$form, $isNew = false) { $serviceLocator = $this->getServiceLocator(); $entityManager = $serviceLocator->get('entity-manager'); //add empty language content to the collection, so that input fields are created $this->addEmptyContent($category); $listingContent = !$isNew ? $category->getContent() : null; $form = new CategoryForm($entityManager, $listingContent); $categoryTree = $this->getServiceLocator()->get('category-tree'); $category2 = !$isNew ? $category : null; $parentElement = $form->get('parent'); $parentElement->setEmptyOption($this->translator->translate('Top')); $parentElement->setValueOptions($categoryTree->getSelectOptions($category2)); $form->bind($category); return true; }