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

 Methods

Constructor

__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()

Parameters

$spec

stringarray\Zend_Config

$options

Gets chosen options array

getChosenOptions() : array

Returns

array

Sets chosen options array

setChosenOptions(array $options) : \OSS_Form_Element_DatabaseDropdown

Parameters

$options

array

Key value pair options for chosen.

Returns

Sets chosen list options from DQL

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()

Parameters

$dql

string

DQL query to get chosen options.

$db

string

Database name if not default, some project may have more then one.

Returns

 Properties

 

$helper

$helper 
 

$_chznOptions

$_chznOptions