Tag Archives: zend

Zend Framework 2: The input was not found in the haystack

Hello friends, When you use select input element in Zend Framework 2 forms, then in some cases we will get an error given below:

How to fix this issue? There are two solutions to resolve this issue. Solution 1: Assign all available values of select input element before setData() method. Let’s we have a… Read More »

Zend Framework 2 – Ajax Pagination and Records Sorting

In any application, record listing with pagination and sorting is very common thing. ZF2 also provides support for pagination. Lets start with an example to understand the concept more clearly. Step 1: Create a database table countries and states

Step 2: Now create database configuration

Step 3: Lets create a new module “Sample”… Read More »

Zend Framework 2 – Pagination and Records Sorting

In any application, record listing with pagination and sorting is very common thing. ZF2 also provides support for pagination. Lets start with an example to understand the concept more clearly. Step 1: Create a database table countries and states

Step 2: Now create database configuration

Step 3: Lets create a new module “Sample”… Read More »

Zend Framework 2: Single routing to manage all routes

In ZF2, many people writes as many routing rules as many routes they need. If there are many routes, then its will create a big list of routing rules whill will result in performation and memory consumption also. If there is no requirement of user friendly or custom routes, then we can manage all routes… Read More »

Zend Framework 2: Multiselect box and select multiple options by default

Many times we need multiselect box in our application. Lets see how ZF2 provides support for this feature. Step 1: Create a simple form SampleForm

Step 2: Now in your IndexController action, create form instance like below

Step 3: Now create index.ctp view like below

That’s all!

Zend Framework 2: Configure Multiple database adapters

Step 1: Consider two databases db1 and db2 with table “countries” in each database.

Step 2: Configure multiple databases in ZF2 in config/global/global.php

Step 3: Create Application/Model/CountryTable.php class to manipulate country database.

Step 4: Create another class to access database table instance:

Step 5: Create invokable under “service_manager” key in global.php… Read More »

Zend Framework 2: Configure database

Creating an Adapter Creating an adapter is done by instantiating the Zend\Db\Adapter\Adapter class.

But this is not a better way to instantiate the adapter. By default, ZF2 considers a predefined configuration key “db” (Zend\Db\Adapter\AdapterServiceFactory) so that we can define database adapter configuration in global.php with key “db”. Also, we need to create a factory… Read More »

Zend Framework 2: Local and Global configuration files

Zend Framework 2: Local and Global configuration files In any application, we have some information/settings which are dependent/independent on the application environment. For handling these information, ZF2 provides local and global configuration files. The config_glob_paths key in the main application file(application.config.php) specify the location and naming of additional configuration files which may be loaded. By… Read More »