Yikes.
You have no custom fields for your object. You really should read the tutorials on extending a basic site. You're trying to do some pretty advanced techniques and you don't have the basics down yet.
class Agent extends Page {
static $db = array('Zip' => 'Text');
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Main", new TextField('Zip','Zip codes'));
return $fields;
}
}
Then you need to update your function:
function doAgentSearch($data, $form)
{
// Ici je vais deviner un peu, puisque je ne connais pas ton modele data.
$zip = $data['Zip'];
if(is_numeric($zip)) {
if($agent = DataObject::get("Agent", "Zip LIKE '%$zip%'"))
Director::redirect($agent->Link());
else Director::redirect('agent-not-found'); // un page que tu as deja crée..
}
else Director::redirect('agent-not-found');
}
Then, run a /dev/build.
In the CMS now, you can list all of the zip codes in the Zip Codes field.
12345 53470 32470 43079
etc..