zend-framework2

How to use a custom form view helper in Zend Framework 2?

此生再无相见时 提交于 2019-12-01 04:47:10
问题 I wrote a form view helper, that extends the Zend\Form\View\Helper\FormMultiCheckbox and overwrites its renderOptions(...) method: <?php namespace MyNamespace\Form\View\Helper; use Zend\Form\View\Helper\FormMultiCheckbox as ZendFormMultiCheckbox; class FormMultiCheckbox extends ZendFormMultiCheckbox { protected function renderOptions(...) { ... $label = $escapeHtmlHelper($label); $labelOpen = $labelHelper->openTag($labelAttributes); switch ($labelPosition) { case self::LABEL_PREPEND:

ZF2: Get module name (or route) in the application layout for menu highlight

假如想象 提交于 2019-12-01 04:25:32
How can I get in ZF2 the current (selected) module name in the application layout? Purpose: My application layout include the main menu of the zf2 app, and every time a module is selected I need to highlight the menu voice of the module. Also I need to set the correct route (url, action) when the menu is made with this for. Every module has a menu voice: <ul class="nav"> <?php foreach ($menu_modules as $mod): $is_active = ($mod['name'] == $CURRENT_MODULE_NAME)?'selected':'';//GET MODULE NAME ?> <!-- class="active" --> <li><a href="#" <?php echo $is_active;?> ><?php echo $mod['title']; ?></a><

Configure multi DB connections on ZF2

瘦欲@ 提交于 2019-12-01 04:23:27
问题 I'm actualy a beginner in ZF2 I managed to use multiple BDD on the same application and it works. (I'm talking about this : configure multiple databases in zf2 ). Though, I'd have a little question... Is it ok to declare my custom factory in global.php ? (in the service_manager thing). Or do I need to declare it inside each module ? (in module.php) Declaring it into global.php actualy works, but I was wondering if it's not breaking the spirit of the framework or something... Thanks for your

How to install Zend Framework 2 Tool with composer

和自甴很熟 提交于 2019-12-01 02:45:12
问题 I can't figure out how to run zf.php (Zend Framework 2 Tool) when bootstrapped with composer. First I bootstrap composer and zftool according to the documentation: $ mkdir tmp && cd tmp $ curl -s https://getcomposer.org/installer | php $ ./composer.phar require zendframework/zftool:dev-master This works fine so far. But when I try to run zf.php, I get errors: $ vendor/zendframework/zftool/zf.php PHP Warning: require_once(/Users/seb/tmp/vendor/zendframework/zftool/vendor/autoload.php): failed

How can I use ZF1 $this->action in ZF2?

末鹿安然 提交于 2019-12-01 01:33:43
My problem is that in ZF2 missing Action View Helper. How can I use for example in layout.phtml (or in other view)? ZF1: $this->action("index", "index") // call IndexController indexAction ZF2: ??? How can i solve this? The problem solved!!! ;) http://www.michaelgallego.fr/blog/?p=223 AlloVince First you need to write a custom helper like this: https://github.com/AlloVince/eva-engine/blob/master/vendor/Eva/View/Helper/Action.php Maybe you need to change the namespace to fit your project, Then register this helper as a invokable helper service in your module config file: 'view_helpers' => array

How to use cookie in Zend Framework 2? [closed]

穿精又带淫゛_ 提交于 2019-12-01 01:31:30
I cant understand how to use cookies in ZF2? Can some one advise some links with set and get cookie? simply use the rememberMe() method on the SessionManager to set a cookie See SessionManager Code on line 260 there also is forgetMe() to remove the cookie additionally you can configure the defaults for your session manager like this: Module.php public function onBootstrap(\Zend\EventManager\EventInterface $e) $config = $e->getApplication() ->getServiceManager(); ->get('Configuration'); $sessionConfig = new SessionConfig(); $sessionConfig->setOptions($config['session']); $sessionManager = new

Zend Framework 2 “Zend Tool Missing” in bin folder

我的未来我决定 提交于 2019-12-01 01:13:29
im newbie in frameworks, but i had no difficulty installing etc the zend 1.x versions. But with ZF2 cant really figure out.... Any recource telling me creating a project using the zend tool i.e. zf.bat or zf.sh from bin directory, but there's none of them in the zf2 bin folder in contrast to zf1. The only files present are autloader_example.php autloader_examples.php classmap_generator.php createAuoloadTestClasses.php docbook_skeleton.php plugin_generator.php can anyone help me anyhow... neet it asap thanx. d Because Zend Framework 2 are under development, this time, we have not a tool to

Zend Framework 2 MVC - Modules Route mapping not working

天大地大妈咪最大 提交于 2019-12-01 01:03:08
I try to follow Akrabats Tutorial the Application/Index is working, the Album part not. I tried it also with the ZendSkeletonModule with no luck. The error in both cases is: album/album (resolves to invalid controller class or alias: album/album) I tried it with ZF2 master and beta4 tag (but beta4 tag gives php error about missing method getEventManager) I took the code from Akrabats Tutorial, and after that failed used the code form the GitHub Repo . Unfortunatly there isnt some Forum or Comment section to ask for help. I found some diffrences in the tutorial and the Skeleton (zfcUser has the

Zend Navigation and RBAC

扶醉桌前 提交于 2019-12-01 00:37:21
I am developing a ZF2 based site. I have a main navigation which stays same regardless of the visitor/user status. Need to add another component/nav, which will depend on the user's status and role. For a visitor the items will be Register Login EN (Actually a drop-down, with other available language) For a logged-in normal user, it will display Profile Logout EN (Language selector as mentioned above) And for some users with specific roles/permission there will be additional items I want to use RBAC, as ACL seems bloated, and also just to check if the current logged in user/role has additional

Zend Framework 2 - Annotation Forms don't work

我怕爱的太早我们不能终老 提交于 2019-11-30 23:56:56
Thanks to @Hikaru-Shindo I looked into AnnotationForms which seem to be the best available as a work-around for ModelForms . But the example shown here doesn't work for me. use Zend\Form\Annotation\AnnotationBuilder; $builder = new AnnotationBuilder(); $form = $builder->createForm('User'); Looking at this code I wonder where the AnnotationBuilder knows where to look for this user form. Especially because in the annotation in the form def there is a lowercase 'user' @Annotation\Name("user") I put the form def code into 'MyModule/Form/UserForm.php' and the lower code into my Controller. Is this