Ben bir Zend_Form var
$form = new My_Form();
$uploadedData = $form->getValues();
Zend_Debug::dump($uploadedData, $form->name,true)
i form değerleri dökümü zaman ve ben bir dize dizisi olsun
array(11) {
["event"] => string(2) "26"
["firstname"] => string(3) "sdf"
["surname"] => string(0) ""
["gender"] => string(1) "M"
["company"] => NULL
["dateOfBirth"] => string(10) "11-11-1977"
["address"] => string(6) "dfasdf"
["address2"] => string(4) "adfs"
["address3"] => string(4) "adfs"
["email"] => string(7) "x@x.com"
["mobile"] => string(0) ""
}
Form benim DB tablo gibi alanların aynı sayıda, DB tablo def
DROP TABLE IF EXISTS `registration`;
CREATE TABLE IF NOT EXISTS `registration` (
`id` int(11) NOT NULL auto_increment,
`event` int(11) NOT NULL,
`firstname` varchar(50) NOT NULL,
`surname` varchar(50) NOT NULL,
`gender` varchar(5) NOT NULL,
`dateofbirth` date NOT NULL,
`address` varchar(50),
`address2` varchar(50),
`address3` varchar(50),
`email` varchar(50) NOT NULL,
`mobile` varchar(50),
`company` int(11),
`sector` int(11),
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
I'm getting a mapping error at the moment, since the DB event column can't take a string, and same with the 'dateofbirth' column
if($form->isValid($formData))
{
$logger->info("valid form");
$table = new Model_DbTable_Registration();
... // apply some custom mapping??
$table->insert($uploadedData);
...
}
I don't want to have to manually create a new array, and map each form field to the correct type by name - it seems like a pain. Is there a smarter way to do this mapping in Zend?