/** * (non-PHPdoc) * @see lib/form/data/collection/phSimpleDataCollection::register() */ public function register(phFormViewElement $element, phNameInfo $name, phCompositeDataCollection $collection) { parent::register($element, $name, $collection); if ($element instanceof phCheckboxElement) { $this->_checkboxValues[$name->getFullName()][] = $element->getRawValue(); } }
/** * (non-PHPdoc) * @see lib/form/data/collection/phSimpleDataCollection::validate() */ public function validate(phFormViewElement $element, phNameInfo $name, phCompositeDataCollection $collection) { /* * go through the name and, if it's an array, build it back up, BUT - skip * the last key if it's an auto key. We do this because checkboxes with auto * key's cannot be mixed with any other data type. */ $nameString = $name->getName(); $hasAutoKey = false; if ($name->isArray()) { $keys = $name->getArrayInfo()->getKeys(); foreach ($keys as $k) { if ($k->isAutoKey()) { $hasAutoKey = true; break; } $nameString .= "[{$k->getKey()}]"; } } if ($element instanceof phSelectListElement && $element->isMultiple()) { if (!$hasAutoKey) { throw new phFormException("Invalid name \"{$name->getFullName()}\" - Multi select list elements must use a name with an auto key"); } else { $data = $collection->find($nameString); if ($data !== null) { throw new phFormException("Cannot register multi-select list at {$name->getFullName()} another data item exists there"); } } } if (array_key_exists($name->getFullName(), $this->_multipleElements)) { throw new phFormException("There is a multi-select list registered at \"{$name->getFullName()}\", you cannot register any other types of data here"); } if ($element instanceof phSelectListElement) { /* * also do uniqueness checks if we are registering a select element */ parent::validate($element, $name, $collection); } }