Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

[solved] limit of silvertripe


Reply


19 Posts   2456 Views

Avatar
UncleCheese

Forum Moderator, 4096 Posts

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.

Avatar
astate

Community Member, 35 Posts

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

Avatar
UncleCheese

Forum Moderator, 4096 Posts

1 April 2009 at 8:55am

Show me your Agent.php class.

Avatar
astate

Community Member, 35 Posts

1 April 2009 at 9:11am

my agent.php [url]http://pastebin.com/m1ef6552d[/url]

Avatar
UncleCheese

Forum Moderator, 4096 Posts

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..

Avatar
astate

Community Member, 35 Posts

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

Avatar
astate

Community Member, 35 Posts

1 April 2009 at 11:14am

Edited: 01/04/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/AgentSearchForm

Line 133 in /home/kbsecuri/www/sapphire/core/Object.php
Source

124
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

Avatar
UncleCheese

Forum Moderator, 4096 Posts

1 April 2009 at 2:53pm

Try DataObject::get_one() instead of DataObject::get()\