/** * (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 phRadioButtonElement) { $this->_radioValues[$name->getFullName()][] = $element->getRawValue(); } }
/** * (non-PHPdoc) * @see lib/form/data/collection/phSimpleDataCollection::getOrCreateArrayDataType() */ protected function getOrCreateArrayDataType(phNameInfo $name, $keys, $currentKeyIndex, phFormViewElement $element, phArrayFormDataItem $currentDataItem) { if ($currentDataItem instanceof phSimpleArrayDataItem) { /* * a simple array data type has been created or gotten. This * means we are at the end of the array and cannot go any * further down so we should return this data item. */ return $currentDataItem; } else { return parent::getOrCreateArrayDataType($name, $keys, $currentKeyIndex, $element, $currentDataItem); } }
public function testValidateArrayOk() { $collection = new phSimpleDataCollection(); $composite = new phSimpleTestCompositeDataCollection(); $composite->_collections[] = $collection; $element = new phSimpleTestElement(); $nameInfo = new phNameInfo('test[]'); $collection->register($element, $nameInfo, $composite); /* * check name set properly */ $this->assertEquals('test', $collection->find('test')->getName(), 'name of array data type set properly'); $collection2 = new phSimpleDataCollection(); $collection2->validate($element, $nameInfo, $composite); $this->assertTrue(true, 'validate passed an array, recognising it is different'); }