zend-framework3

Zend Framework 3 Form Fieldset

ぐ巨炮叔叔 提交于 2020-01-05 09:09:20
问题 Hy, I'm really new to Zend-Framework 3 and I'm practicing OOP, I can't find a simple explanation/tutorial on making a Zend Form with a fieldset and legend. Basically I'm trying to create this in HTML: <form name="my_name"> <fieldset> <legend>My legend value</legend> <input type="checkbox" name="name_1" value="value_1">Value 1</input> <input type="checkbox" name="name_2" value="value_2">Value_2</input> <input type="checkbox" name="name_3" value="value_3">Value_3</input> </fieldset> <input type

How to implement acl and authorization in Module.php in zf3

会有一股神秘感。 提交于 2020-01-05 05:00:21
问题 I am working on Album Application in zf3.I added acl functionality to the application like this: AlbumController.php class AlbumController extends AbstractActionController { protected $role; public function onDispatch(\Zend\Mvc\MvcEvent $e) { $userSession = new Container('user'); if (!isset($userSession->email)) { return $this->redirect()->toRoute('login'); } else { $this->role = $userSession->role; parent::onDispatch($e); } } public function checkPermission($role,$action) { if($role ==

ZF2/3 Load Modules from Database

不想你离开。 提交于 2020-01-03 03:57:07
问题 I would like to know if there is a way to load modules from a database table in zend framework 2 preferable 3? I want to be able to dynamically disable or enable modules based on a status column inside a database table 回答1: I'm pretty sure you can accomplish this by attaching listener to some of ModuleManager events. There are docs for v3 https://docs.zendframework.com/zend-modulemanager/module-manager/ and v2 https://framework.zend.com/manual/2.1/en/modules/zend.module-manager.module-manager

ZF3 Multiple Modules and Multiple Layouts

微笑、不失礼 提交于 2019-12-31 04:34:24
问题 I'm working on a multi module site using Zend Framework 3 for ~6 months, learning as I go along. For the most part I have been pretty successful but I have run across a problem that I will describe below. There are ~20 modules and I have determined that in each modules module.config.php I should define a unique name for the Layout like this. Namespace Sample Controller Name: SampleController.php module/Sample/view/sam_layout.phtml And in the Sample modules module.config.php 'view_manager' =>

How to set different layouts for different modules in Zend Framework 3

℡╲_俬逩灬. 提交于 2019-12-25 09:18:44
问题 How can I set different layouts for different modules in Zend Framework 3 instead of using single one same layout template all around the site? 回答1: 

Zend Framework - Issue 
> You may want to alter the layout based on the current module. This requires (a) detecting if the controller matched in routing belongs to this module, and then (b) changing the template of the View Model. 

 The place to do these actions is in a listener. It should listen either to the “route” event at low (negative)

Set custom filter plugin inside servicemanager config zend framework

旧街凉风 提交于 2019-12-25 07:44:45
问题 I have the following code in my application user form that creates the input filter for the address2 element . $inputFilter = new InputFilter(); $inputFilter->add([ 'name' => 'address2', 'required' => true, 'filters' => [ ['name'=>'StringTrim'], ['name'=>'Administration\Filter\Ucwords'] ] ]); As you can see, I have the class name set as the name of the filter. I get the following error: A plugin by the name "Administration\Filter\Ucwords" was not found in the plugin manager Zend\Filter

ZF3 - Unit testing controllers, POST/GET data not sending

梦想的初衷 提交于 2019-12-25 03:38:23
问题 I have define below in unit test $p = new Parameters(); $p->set('email','test@gmail.com'); $p->set('password','abcd'); $p->set('username','abcd'); $this->getRequest()->setMethod('POST',$p); $this->getRequest()->setPost($p); $this->dispatch('/default/register'); $this->assertModuleName('default'); //assertActionName $this->assertResponseStatusCode(200); $this->assertControllerName(TestController::class); $this->assertControllerClass('TestController'); $this->assertActionName('register'); $this

ZF3 Get browser Language

爷,独闯天下 提交于 2019-12-24 23:58:57
问题 There are a several of ways to get the browser language in Zend Framework 3. Can anyone tell me what should be the right way ? I was thinking about getting the locale and substract the language from it ? 回答1: $this->request->getHeader('Accept-Language')->getPrioritized()[0]->getPrimaryTag(); or $this->request->getHeader('Accept-Language')->getPrioritized()[0]->getLanguage(); 回答2: In ZF 2 , somewhere in Controller $translator = $this->getServiceLocator()->get('translator'); $t = $translator-

How to trigger fieldset factory in ZF3

♀尐吖头ヾ 提交于 2019-12-24 15:26:29
问题 I need to use factory for fieldset. I know how to do it for form, but how to do it for fieldset? The form code is: namespace Application\Form; use Application\Fieldset\Outline; use Zend\Form\Element; use Zend\Form\Form; class Message extends Form { public function __construct() { parent::__construct('message'); $this->setAttribute('method', 'post'); $this->add([ 'type' => Outline::class, 'options' => [ 'use_as_base_fieldset' => true, ], ]); $this->add([ 'name' => 'submit', 'attributes' => [

How to register custom form view helper in Zend Framework 3

允我心安 提交于 2019-12-23 20:41:50
问题 I am migrating an inherited Zend Framework 2 application to Zend Framework 3 and have run into a bit of difficulty registering my custom form view helpers. The helpers worked when the app was using version 2 and are mainly used for adding tag attributes for accessibility. For example this is a custom FormText.php helper. <?php namespace Application\Form\View\Helper; use Zend\Form\ElementInterface; use Zend\Form\View\Helper\FormInput; class FormText extends FormInput { /** * Attributes valid