/**
	 * Load rendered schema data, usually from a Model declaration, for this column.
	 *
	 * @param array $schema
	 *
	 * @throws \Exception
	 */
	public function setSchema($schema){
		
		// Load all the data from the parent object
		parent::setSchema($schema);
		
		// And this one has options!
		if(!\Core\is_numeric_array($schema['options'])){
			$this->options = array_keys($schema['options']);
		}
		else{
			$this->options = $schema['options'];
		}
	}
Beispiel #2
0
	public function set($key, $value) {
		$key = strtolower($key);

		switch ($key) {
			case 'class':
				$this->classnames[] = $value;
				break;
			case 'value': // Drop into special logic.
				$this->setValue($value);
				break;
			case 'label': // This is an alias for title.
				$this->_attributes['title'] = $value;
				break;
			case 'options':
				// This will require a little bit more attention, as if only the title
				// is given, use that for the value as well.
				if (!is_array($value)) {
					$this->_attributes[$key] = $value;
				}
				elseif(\Core\is_numeric_array($value)) {
					$o = array();
					foreach ($value as $v) {
						$o[$v] = $v;
					}
					$this->_attributes[$key] = $o;
				}
				else{
					// It's an associative or other array, the keys are important!
					$this->_attributes[$key] = $value;
				}
				break;
			case 'autocomplete':
				if($value === false || $value === '0' | $value === 0 || $value === 'off'){
					$this->_attributes[$key] = 'off';
				}
				elseif($value === true || $value === '1' || $value === 1 || $value === 'on' || $value === ''){
					$this->_attributes[$key] = 'on';
				}
				else{
					// Resolve this to an actual URL using Core's built-in resolution system.
					$this->_attributes[$key] = \Core\resolve_link($value);
				}
				break;
			case 'persistent':
				$this->persistent = $value;
				break;
			default:
				$this->_attributes[$key] = $value;
				break;
		}
	}