Form element text field with database dropdown
NOTICE: It requires chosen library
author | Barry O'Donovan |
---|---|
author | The Skilled Team of PHP Developers at Open Solutions |
category | OSS |
package | OSS_Form |
subpackage | OSS_Form_Element |
copyright | Copyright (c) 2007 - 2013, Open Source Solutions Limited, Dublin, Ireland |
license | New BSD License |
__construct(string | array | \Zend_Config $spec, $options) : void
$spec may be: - string: name of element - array: options with which to configure element - Zend_Config: Zend_Config with options for configuring element
Chosen options can be set in array two ways first by DQL second simple array.
To set options by DQL $options array structure should be like: [ 'dql' => "select u.username from \Entities\User where u.username IS NOT NULL", //mandatory 'db' => "default" //Optional if db is not default. Some project may have more then one. ]
To set options by array $options array structure should be like: [ 'options' => [ 'option1' => 'option1', 'option2' => 'option2', 'option3' => 'option3' ], //mandatory ]
see | \global\setChosenOptions() |
---|---|
see | \global\setChosenOptionsByDql() |
string
array
\Zend_Config
getChosenOptions() : array
array
setChosenOptions(array $options) : \OSS_Form_Element_DatabaseDropdown
array
Key value pair options for chosen.
setChosenOptionsByDql(string $dql, string $db) : \OSS_Form_Element_DatabaseDropdown
Queries database with given DQL query then makes a key value array where key equals to value. And then calls setChosesOptions.
NOTE: DQL query must request data from only one field. e.g.: select u.username from \Entities\User u WHERE u.username IS NOT NULL
see | \global\setChosenOptions() |
---|
string
DQL query to get chosen options.
string
Database name if not default, some project may have more then one.
$helper
$_chznOptions