I need a city search feild case.
when the client write the city, the client need to be redirected to a contact page the agent of this city.
The agent have many city in this list.
How i can do it with silverstripe ? It's possible ?
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
I need a city search feild case.
when the client write the city, the client need to be redirected to a contact page the agent of this city.
The agent have many city in this list.
How i can do it with silverstripe ? It's possible ?
Do I speak well?
Sorry i don't speak english very well.
Yes, you can do this. There are a few pieces to it, though. Can you give a little bit more detail and I'll write something up for you tomorrow when I'm not typing on my iPhone? :)
ok :)
All Agents have a contact page différent.
All Agents serve many Postal Code (canada) (G6C 1E2, G2E 4W9, J01 2T0, etc). The Agents can be have more then 20 postal code.
i need only one search field
Your Postal Code : __________
When the visitor type the postal code, the contact page of the Agent who have this postal code open.
Thanks for your help
Est-ce que ta langue preferrée est francais? Je peux essayer de l'éxpliquer en francais si tu veux... J'ai remarqué que tu viens de Canada. (Desolé, je ne peux pas trouver tous les accents sur mon ordinateur). :)
D'accord... je vais assumer que tu veux la forme sur aucune page, n'importe ou. Mettons alors le function dans la classe Page_Controller:
function AgentSearchForm()
{
return new Form(
$this,
"AgentSearchForm",
new FieldSet(new TextField('Zip')),
new FieldSet(new FormAction('doAgentSearch','Search')
);
}
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 = '$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');
}
Sur la template:
$AgentSearchForm
Sans voir tous tes PHP classes pertinentes, c'est loin de parfait, mais j'éspére que cette code t'assiste un peu. Laisse-moi savoir si tu as des questions.
Peut-etre tu peux m'assiste avec mon fraincais en retour. :) Ca fait des années que je n'ai pas parler francais. Depuis.... le lycée, je crois..
merci.
sorry, i am a beginner.
I have a error a this line
new FieldSet(new FormAction('doAgentSearch','Search')
);
Silverstripe don't want a ";"
Changez:
new FieldSet(new FormAction('doAgentSearch','Search')
a
new FieldSet(new FormAction('doAgentSearch','Search') )
it's ok thanks :)
Now i test this