zend-framework2

ZF2: How do I use InArray validator to validate Multiselect form element?

﹥>﹥吖頭↗ 提交于 2019-12-01 21:01:01
I have a ZF2 form where I had to disable native validators, for a specific reason. Then, when adding elements programatically to the form I also add validators. One of the elements is a Multiselect array. $form->add( array( 'type' => 'Zend\Form\Element\Select', 'options' => array( ( 'label' => 'few items', 'value_options' => Array ( 'one' => 'one', 'two' => 'two', 'three' => 'three', 'four' => 'four', ) ), 'attributes' => array ( 'multiple' => 'multiple', 'value' => array('two','three'), 'required' => 1, 'id' => 'few_items' ), 'name' => 'few_items' )); Also, I'm going to add an InArray

How to redirect to the login page with BjyAuthorize

落花浮王杯 提交于 2019-12-01 20:32:40
I want to redirect some pages to the login page instead of page 403. By default BjyAuthorize redirects everything to a 403 page. Is it possible to configure this behavior? I found this: RedirectionStrategy . How do I use this? Finally I got it. With version 1.2.* of BjyAuthorize, you simply add in config/autoload/bjyauthorize.global.php : return array( 'bjyauthorize' => array( 'unauthorized_strategy' => 'BjyAuthorize\View\RedirectionStrategy', // [...] ), ); And it will redirect you to the route configured in vendor/bjyoungblood/bjy-authorize/src/BjyAuthorize/View/RedirectionStrategy.php Check

zend framework 2 base path access in controller

随声附和 提交于 2019-12-01 19:41:35
问题 How can i call basePath helper in controller in ZF 2. I have to redirect to a particular url in which i need base path. return $this->redirect()->toUrl($basePath.'/application/rent/search'); 回答1: Here's an easy method to make all view helpers available from within the controllers. So you should be able to use the following: public function someAction() { $renderer = $this->serviceLocator->get('Zend\View\Renderer\RendererInterface'); $url = $renderer->basePath('/application/rent/search');

ZF2: How to attach module specific listener for dispatch.error

可紊 提交于 2019-12-01 19:38:18
Is there a way I can attach an event listener for the event dispatch.error in Zend Framework 2, where that listener will only be attached to an EventManager related to the Module.php? I have achieved this by attaching listener for dispatch to the global SharedManager and passing the current Module.php's namespace as first param. It works beautifully, but does NOT work, when I try the same for dispatch.error . Here's an example in Module.php: public function init(ModuleManager $moduleManager) { $sharedManager = $moduleManager->getEventManager()->getSharedManager(); $sharedManager->attach(_

Zend Framework 2 - AJAX Request from other server

狂风中的少年 提交于 2019-12-01 18:53:35
问题 I have 2 domains (domain A, domain B). On domain A is placed ZF2 application, and everything is ok. On domain B is placed Landing Page (small site with form to collect data). From Landing Page I want send form data to application on domain A (AJAX Request). Unfortunatelly ZF2 app on domain A didn't receive data, and didn't show results. Everything is ok when I make AJAX Request from same domain where ZF2 app is. I tried use JSONP but without success. I don't have any other clue how to force

zend framework 2 base path access in controller

痴心易碎 提交于 2019-12-01 18:36:55
How can i call basePath helper in controller in ZF 2. I have to redirect to a particular url in which i need base path. return $this->redirect()->toUrl($basePath.'/application/rent/search'); aimfeld Here's an easy method to make all view helpers available from within the controllers. So you should be able to use the following: public function someAction() { $renderer = $this->serviceLocator->get('Zend\View\Renderer\RendererInterface'); $url = $renderer->basePath('/application/rent/search'); $redirect = $this->plugin('redirect'); return $redirect->toUrl($url); } The full base url (http://...)

ZendDeveloperTools module not displaying a toolbar in ZF2 beta5

情到浓时终转凉″ 提交于 2019-12-01 17:47:19
I'm trying to install the ZendDeveloperTools modules for ZF2 beta5. Here are the steps I followed so far: -Successfully installed ZendSkeletonApplication . -Downloaded the module into my ./vendor directory. -Enabled the module in ./config/application.config.php : <?php return array( 'modules' => array( 'Application', 'ZendDeveloperTools', // Added this line ), 'module_listener_options' => array( 'config_glob_paths' => array( 'config/autoload/{,*.}{global,local}.php', ), 'module_paths' => array( './module', './vendor', ), ), ); -Copied ./vendor/ZendDeveloperTools/config/zenddevelopertools.local

Get the posted data from Form in Zend Framework 2

穿精又带淫゛_ 提交于 2019-12-01 17:40:34
Im new to Zend Framework, so asking a basic question. I want to get the posted data, in general from one field in a form, I wanted to get the data for debugging purposes. For example I have a form with fields like username, age and so on. In my controller in addAction(), I want to fetch the username, store it in a variable and use it for debugging purposes. I hope I made it clear. In case if my question is unclear then please do let me know. Thanks You're not very clear so I suggets a few solutions... If you need the plain POST value, you can access it using $this->getRequest()->getPost('name'

ZendDeveloperTools module not displaying a toolbar in ZF2 beta5

試著忘記壹切 提交于 2019-12-01 17:30:52
问题 I'm trying to install the ZendDeveloperTools modules for ZF2 beta5. Here are the steps I followed so far: -Successfully installed ZendSkeletonApplication. -Downloaded the module into my ./vendor directory. -Enabled the module in ./config/application.config.php : <?php return array( 'modules' => array( 'Application', 'ZendDeveloperTools', // Added this line ), 'module_listener_options' => array( 'config_glob_paths' => array( 'config/autoload/{,*.}{global,local}.php', ), 'module_paths' => array

How to implement beberlei doctrine extensions in zend framework 2

无人久伴 提交于 2019-12-01 16:50:41
i dont know how to integrate the beberlei doctrine-extensions: https://github.com/beberlei/DoctrineExtensions in Zend Framework 2 with Doctrine Module. I installed it with composer: "beberlei/DoctrineExtensions": "dev-master" I tried in my module.config.php from th application module: 'doctrine' => array( 'driver' => array( __NAMESPACE__ .'_driver' => array( 'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver', 'cache' => 'array', 'paths' => array(__DIR__ . '/../src/'.__NAMESPACE__.'/Entity') ), 'orm_default' => array( 'drivers' => array( __NAMESPACE__.'\Entity' => __NAMESPACE__. '_driver