21295 Posts in 5734 Topics by 2602 members
| Go to End | Next > | |
| Author | Topic: | 1899 Views |
-
Re: [solved] limit of silvertripe

1 April 2009 at 8:12am
Le function correct est au-dessous:
function AgentSearchForm()
{
return new Form(
$this,
"AgentSearchForm",
new FieldSet(new TextField('Zip')),
new FieldSet(new FormAction('doAgentSearch','Search'))
); // ligne 27
}Il semble que tu as bouge le ")" en lieu d'ajouter.
-
Re: [solved] limit of silvertripe

1 April 2009 at 8:44am
ok, now i have a new search field.
where i write zip list of my agents ?
I read and read the code ... but
-
Re: [solved] limit of silvertripe

1 April 2009 at 9:22am
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..
-
Re: [solved] limit of silvertripe

1 April 2009 at 9:56am
I read and i think understant the tutorial 1 and 2.
Now it's don't work, but check this.thanks
-
Re: [solved] limit of silvertripe

1 April 2009 at 11:14am Last edited: 1 April 2009 1:39pm
When the Postal are good, i have error
this line of code give me a probleme in my Agent.php
Director::redirect($agent->Link());
[User Error] Object::__call() Method 'Link' not found in class 'DataObjectSet'
POST /agent/AgentSearchFormLine 133 in /home/kbsecuri/www/sapphire/core/Object.php
Source124
125 } else if($config['function_str']) {
126 $function = Object::$extraMethods[$this->class][strtolower($methodName)]['function'] = create_function('$obj, $args', $config['function_str']);
127 return $function($this, $args);
128
129 } else {
130 user_error("Object::__call() Method '$methodName' in class '$this->class' an invalid format: " . var_export(Object::$extraMethods[$this->class][$methodName],true), E_USER_ERROR);
131 }
132 } else {
133 user_error("Object::__call() Method '$methodName' not found in class '$this->class'", E_USER_ERROR);
134 }
135 }
136 -
Re: [solved] limit of silvertripe

1 April 2009 at 2:53pm
Try DataObject::get_one() instead of DataObject::get()\
| 1899 Views | ||
| Go to Top | Next > |

