src/ItePHP/Component/Form/FormBuilder.php
public function getData(){
		$data=[];
		foreach($this->fields as $field){
			if(preg_match('/^(.*?)(\[.*\])$/',$field->getName(),$result)){
				if($result[2]==''){
					//FIXME autoincrement field
				}
				else{

					if(!preg_match_all("/\[(.*?)\]/", $result[2], $resultDeep)){
						throw new \Exception('Invalid field name.');//FIXME dedicate exception
					}
					$storage=&$data[$result[1]];
					foreach($resultDeep[1] as $deep){
						if(!isset($storage[$deep])){
							$storage[$deep]=[];
						}
						$storage=&$storage[$deep];
					}
					$storage=$field->getData();
				}
			}
			else{
				$data[$field->getName()]=$field->getData();
			}
		}

		return $this->transformer->decode($data);
	}
public function getData(){
		$data=[];
		foreach($this->fields as $field){
			if(preg_match('/^(.*?)(\[.*\])$/',$field->getName(),$result)){
				if($result[2]==''){
					//FIXME autoincrement field
				}
				else{

					if(!preg_match_all("/\[(.*?)\]/", $result[2], $resultDeep)){
						throw new \Exception('Invalid field name.');//FIXME dedicate exception
					}
					$storage=&$data[$result[1]];
					foreach($resultDeep[1] as $deep){
						if(!isset($storage[$deep])){
							$storage[$deep]=[];
						}
						$storage=&$storage[$deep];
					}
					$storage=$field->getData();
				}
			}
			else{
				$data[$field->getName()]=$field->getData();
			}
		}

		return $this->transformer->decode($data);
	}
public function getData ( ) { $ data = [ ] ; foreach ( $ this -> fields as $ field ) { if ( preg_match ( '/^(.*?)(\[.*\])$/' , $ field -> getName ( ) , $ result ) ) { if ( $ result [ 2 ] == '' ) { //FIXME autoincrement field } else { if ( ! preg_match_all ( "/\[(.*?)\]/" , $ result [ 2 ] , $ resultDeep ) ) { throw new \ Exception ( 'Invalid field name.' ) ; //FIXME dedicate exception } $ storage = & $ data [ $ result [ 1 ] ] ; foreach ( $ resultDeep [ 1 ] as $ deep ) { if ( ! isset ( $ storage [ $ deep ] ) ) { $ storage [ $ deep ] = [ ] ; } $ storage = & $ storage [ $ deep ] ; } $ storage = $ field -> getData ( ) ; } } else { $ data [ $ field -> getName ( ) ] = $ field -> getData ( ) ; } } return $ this -> transformer -> decode ( $ data ) ; }
Get data from fields
@return mixed[]
@throws \Exception
Get data from fields