All Zend_Form classes are configurable using
Zend_Config; you can either pass a
Zend_Config object to the constructor or pass it in
with setConfig(). Let's look at how we might create the
above form using an INI file. First, let's follow the
recommendations, and place our configurations into sections
reflecting the release location, and focus on the 'development'
section. Next, we'll setup a section for the given controller
('user'), and a key for the form ('login'):
[development] ; general form metainformation user.login.action = "/user/login" user.login.method = "post" ; username element user.login.elements.username.type = "text" user.login.elements.username.options.validators.alnum.validator = "alnum" user.login.elements.username.options.validators.regex.validator = "regex" user.login.elements.username.options.validators.regex.options.pattern = "/^[a-z]/i" user.login.elements.username.options.validators.strlen.validator = "StringLength" user.login.elements.username.options.validators.strlen.options.min = "6" user.login.elements.username.options.validators.strlen.options.max = "20" user.login.elements.username.options.required = true user.login.elements.username.options.filters.lower.filter = "StringToLower" ; password element user.login.elements.password.type = "password" user.login.elements.password.options.validators.strlen.validator = "StringLength" user.login.elements.password.options.validators.strlen.options.min = "6" user.login.elements.password.options.required = true ; submit element user.login.elements.submit.type = "submit"
You would then pass this to the form constructor:
<?php
$config = new Zend_Config_Ini($configFile, 'development');
$form = new Zend_Form($config->user->login);
and the entire form will be defined.




