* @license PHP License * @package WB * @subpackage db */ WBClass::load('WBDatasource_FormAttribute'); /** * Populate Form Element's Values With Initial Value * * This works only for items (Enum, RadioGroup, SwitchGroup). * * @version 0.1.0 * @package WB * @subpackage db */ class WBDatasource_FormAttribute_AddInitial extends WBDatasource_FormAttribute { /** * Configuration Parameter * @var array */ protected $config = array( 'class' => '' ); /** * Get Attribute's Value * * Simply append current value as another item in list * * @param mixed $current actual attribute value * @return array */ protected function getAttributeValue($current) { $iv = $this->getInitialValue(); if (empty($iv)) { return $current; } if (!is_array($current)) { $current = array(); } $current[] = array( 'value' => $iv, 'label' => $iv, 'class' => $this->config['class'] ); return $current; } }