* @license PHP License * @package WB * @subpackage db */ WBClass::load('WBDatasource_FormAttribute'); /** * Populate form element's values from any table * * Use table data to populate values * * @version 0.1.0 * @package WB * @subpackage db */ class WBDatasource_FormAttribute_Static extends WBDatasource_FormAttribute { /** * configuration parameter * @var array */ protected $config = array( 'type' => 'list', 'value' => '', ); /** * get attribute's value * * Use dicktionary to fetch list of values * * @param mixed $current actual attribute value * @return array */ protected function getAttributeValue($current) { switch ($this->config['type']) { case 'list': return $this->getAttributeValue4List($current); break; default: break; } return $current; } private function getAttributeValue4List($current) { if (!is_array($current)) { $current = array(); } foreach ($this->config['value'] as $v) { $current[] = $v; } return $current; } }