zend-framework2

how to disable inArray validator forms in zend framework2

馋奶兔 提交于 2019-11-30 18:28:59
问题 i use this in my Form: $this->add(array( 'type' => 'Zend\Form\Element\Select', 'name' => 'county', 'registerInArrayValidator' => false, 'attributes' => array( 'id' => 'county', 'options' => array( //'null'=>'[Select county]', ), ), 'options' => array( 'label' => 'county', ), )); and set value county field with js. after validation, i get error : haystack option is mandatory 回答1: Add the disable_inarray_validator to the options: $this->add(array( ... 'options' => array( 'disable_inarray

Zend Framework 2 filter / validate array of contents

感情迁移 提交于 2019-11-30 18:10:37
问题 How do I apply a filter to a field element with the contents of an array? For example: $this->add( "name" => "tags", "type" => "text", "filter" => array( array("name" => "StripTags"), array("name" => "StringTrim") ) ); $tags[0] = "PHP"; $tags[1] = "CSS"; If I attempt to filter I receive an error saying a scalar object is excepted, array given. 回答1: This isn't really possible at this time. Your best bet is to use a Callback filter and filter each Item individually. Something like this $this-

Zend Framework 2 - Annotation Forms don't work

梦想与她 提交于 2019-11-30 18:07:36
问题 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

Multiple namespaces under same module in ZF2

谁都会走 提交于 2019-11-30 17:40:34
问题 I'm having trouble configuring multiple namespaces/classes under same module. For example, I have a module called "Account", in which I'd like to include all account related classes (companies: 'accounts', users: 'users', external api: 'api' etc.. ). Module structure looks like this.. /Account - Module.php - /config - /view - /src - /Account - /Controller (AccountController.php) - /Form (AccountForm.php) - /Model (Account.php + AccountTable.php) - /User - /Controller (UserController.php) -

LEFT JOIN in ZF2 using TableGateway

做~自己de王妃 提交于 2019-11-30 17:15:33
I have a table: *CREATE TABLE IF NOT EXISTS `blogs_settings` ( `blog_id` int(11) NOT NULL AUTO_INCREMENT, `owner_id` int(11) NOT NULL, `title` varchar(255) NOT NULL, `meta_description` text NOT NULL, `meta_keywords` text NOT NULL, `theme` varchar(25) NOT NULL DEFAULT 'default', `is_active` tinyint(1) NOT NULL DEFAULT '1', `date_created` int(11) NOT NULL, PRIMARY KEY (`blog_id`), KEY `owner_id` (`owner_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;* And the second table: *CREATE TABLE IF NOT EXISTS `users` ( `user_id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(255) NOT

composer error while updating “.git directory is missing”

怎甘沉沦 提交于 2019-11-30 17:08:37
When I Updating zf-commons/zfc-admin using composer, it gives an RuntimeException error saying that [RuntimeException] The .git directory is missing from /var/www/site2.com/vendor/zf-commons/zfc -admin, see http://getcomposer.org/commit-deps for more information Since this error i cannot update any other modules in framework. When ever I have "issues" with composer the first thing I do is delete the vendor folder and do a "composer update" You could also try to delete just that one component "vendor/zf-commons" The easiest way is to remove the install folder of that component before making the

Set a generic layout for all modules in Zend framework 2

放肆的年华 提交于 2019-11-30 17:04:44
I'm working on a ZF2 Project, and I have some modules in my directories : /module/module1 /module/module2 /module/module3 /module/module4 [...] But, in each module I also have a specific layout, respectively : /module/module1/view/layout/layout.phtml /module/module2/view/layout/layout.phtml /module/module3/view/layout/layout.phtml /module/module4/view/layout/layout.phtml My question is : How can I set a generic layout for all my modules without to have to modify each layout when I want. Thank you You can set the layout to be what ever you want in each modules config, just change the layout to

LEFT JOIN in ZF2 using TableGateway

自古美人都是妖i 提交于 2019-11-30 16:31:42
问题 I have a table: *CREATE TABLE IF NOT EXISTS `blogs_settings` ( `blog_id` int(11) NOT NULL AUTO_INCREMENT, `owner_id` int(11) NOT NULL, `title` varchar(255) NOT NULL, `meta_description` text NOT NULL, `meta_keywords` text NOT NULL, `theme` varchar(25) NOT NULL DEFAULT 'default', `is_active` tinyint(1) NOT NULL DEFAULT '1', `date_created` int(11) NOT NULL, PRIMARY KEY (`blog_id`), KEY `owner_id` (`owner_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;* And the second table: *CREATE

Zend Framework 2 - Translate Standard Form Validation and Error messages

给你一囗甜甜゛ 提交于 2019-11-30 15:36:26
I'm writing a complete German application and therefore need to set basically everything to German. My question: What is the best and easiest way to set for example the form validation to German? I found this page but couldn't figure out how to get this code working: Zend_Validate_Abstract::setDefaultTranslator($translate); Could anyone give me some advice how to use this? Edit: Thanks to @Gordon I put the following into my Application/Module.php: use Zend\I18n\Translator\Translator; use Zend\Validator\AbstractValidator; class Module { public function onBootstrap(MvcEvent $e) { ... $translator

How to log something to Zend Developer Tools toolbar?

﹥>﹥吖頭↗ 提交于 2019-11-30 15:33:53
It's posible to log to Zend Developer Tools toolbar some variable in ZF2 controller? Well, I have created a Collector to add personal information on ZendDevelopersTool. You need info from a Controller, and that's I never had tried to do. :) I gonna show you how I created the Collector, and maybe you can find some way to take info from the Controller. In your MyModule\module.config.php /* ZendDeveloperTools Configuration */ 'invokables' => array( 'MyModule\ConfigCollector' => 'MyModule\Collector\ConfigCollector', ), 'view_manager' => array( 'template_map' => array( 'zend-developer-tools/toolbar