Jump to:

23491 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » [solved] limit of silvertripe

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

Page: 1 2 3
Go to End
Author Topic: 2260 Views
  • UncleCheese
    Avatar
    4085 Posts

    Re: [solved] limit of silvertripe Link to this post

    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.

  • astate
    Avatar
    Community Member
    35 Posts

    Re: [solved] limit of silvertripe Link to this post

    ok, now i have a new search field.

    where i write zip list of my agents ?

    I read and read the code ... but

  • UncleCheese
    Avatar
    4085 Posts

    Re: [solved] limit of silvertripe Link to this post

    Show me your Agent.php class.

  • astate
    Avatar
    Community Member
    35 Posts
  • UncleCheese
    Avatar
    4085 Posts

    Re: [solved] limit of silvertripe Link to this post

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

  • astate
    Avatar
    Community Member
    35 Posts

    Re: [solved] limit of silvertripe Link to this post

    I read and i think understant the tutorial 1 and 2.
    Now it's don't work, but check this.

    thanks

  • astate
    Avatar
    Community Member
    35 Posts

    Re: [solved] limit of silvertripe Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: [solved] limit of silvertripe Link to this post

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

    2260 Views
Page: 1 2 3
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.