protected function _addModelLabel($id) { $defaults = array('label' => ucfirst(Garp_Spawn_Util::underscored2readable(Garp_Spawn_Util::camelcased2underscored($this['id'])))); foreach ($defaults as $prop => $defaultValue) { if (!array_key_exists($prop, $this) || is_null($this[$prop])) { $this[$prop] = $defaultValue; } } }
protected function _setConditionalDefaults(array $config) { if (!array_key_exists('type', $config)) { foreach ($this->_defaultTypeByNameEnding as $ending => $type) { if (Garp_Spawn_Util::stringEndsIn($ending, $this->name)) { $this->type = $type; } } } if (!array_key_exists('maxLength', $config)) { switch ($this->name) { case 'name': case 'subtitle': $this->maxLength = self::TEXTFIELD_MAX_LENGTH; break; case 'id': $this->maxLength = 8; break; case 'email': $this->maxLength = 50; break; default: if (Garp_Spawn_Util::stringEndsIn('name', $this->name)) { $this->maxLength = self::TEXTFIELD_MAX_LENGTH; } } } if (!array_key_exists('multiline', $config) && $this->isTextual()) { $this->multiline = !$this->maxLength || $this->maxLength > self::TEXTFIELD_MAX_LENGTH; } if ($this->type === 'checkbox') { $this->required = false; } if (!array_key_exists('label', $config) || !$config['label']) { $this->label = Garp_Spawn_Util::underscored2readable(Garp_Spawn_Util::stringEndsIn('_id', $this->name) ? substr($this->name, 0, -3) : $this->name); } else { $this->label = ucfirst($this->label); } $this->required = (bool) $this->required; }