Esempio n. 1
0
 public function getServiceConfig()
 {
     return array('factories' => array('doctrine.entitymanager' => new \DoctrineORMModule\Service\EntityManagerFactory('orm_default'), 'Admin\\Form\\Product' => function ($sm) {
         $form = new Form\Product();
         $em = $sm->get('doctrine.entitymanager');
         $taxes = $em->getRepository("ErsBase\\Entity\\Tax")->findAll();
         $options = array();
         foreach ($taxes as $tax) {
             $options[$tax->getId()] = $tax->getName() . ' - ' . $tax->getPercentage() . '%';
         }
         $form->get('tax_id')->setValueOptions($options);
         return $form;
     }, 'Admin\\Form\\Role' => function ($sm) {
         $form = new Form\Role();
         $em = $sm->get('doctrine.entitymanager');
         $roles = $em->getRepository("ErsBase\\Entity\\UserRole")->findBy(array(), array('roleId' => 'ASC'));
         $options = array();
         $options[null] = 'no parent';
         foreach ($roles as $role) {
             $options[$role->getId()] = $role->getRoleId();
         }
         $form->get('Parent_id')->setValueOptions($options);
         return $form;
     }, 'Admin\\Form\\ProductVariant' => function ($sm) {
         $form = new Form\ProductVariant();
         $options = array();
         $options['text'] = 'Text';
         $options['date'] = 'Date';
         $options['select'] = 'Select';
         $form->get('type')->setValueOptions($options);
         return $form;
     }, 'Admin\\InputFilter\\User' => function ($sm) {
         $inputFilter = new InputFilter\User();
         $inputFilter->setServiceLocator($sm);
         return $inputFilter;
     }, 'Admin\\InputFilter\\AcceptBuyerChange' => function ($sm) {
         $inputFilter = new InputFilter\AcceptBuyerChange();
         $inputFilter->setServiceLocator($sm);
         return $inputFilter;
     }, 'Admin\\InputFilter\\AcceptParticipantChangeItem' => function ($sm) {
         $inputFilter = new InputFilter\AcceptParticipantChangeItem();
         $inputFilter->setServiceLocator($sm);
         return $inputFilter;
     }, 'Admin\\InputFilter\\AcceptParticipantChangePackage' => function ($sm) {
         $inputFilter = new InputFilter\AcceptParticipantChangePackage();
         $inputFilter->setServiceLocator($sm);
         return $inputFilter;
     }, 'Admin\\InputFilter\\AcceptMovePackage' => function ($sm) {
         $inputFilter = new InputFilter\AcceptMovePackage();
         $inputFilter->setServiceLocator($sm);
         return $inputFilter;
     }));
 }
Esempio n. 2
0
 public function productAddAction()
 {
     $id = (int) $this->params()->fromRoute('id', 0);
     $request = $this->getRequest();
     $productForm = new Product();
     $productForm->get('provider_id')->setValue($id);
     $providerDao = $this->getServiceDao('Model\\Dao\\ProviderDao');
     $providerData = $providerDao->getById($id);
     $view['provider'] = $providerData;
     $categories = $providerData->categories == 0 ? 0 : explode(',', $providerData->categories);
     $cat = $this->getCategorySelect($categories);
     $productForm->get('productCategories')->setValueOptions($cat);
     $view['productForm'] = $productForm;
     return new ViewModel($view);
 }