Jump to:

23368 Posts in 18143 Topics by 2863 members

General Questions

SilverStripe Forums » General Questions » select in admin area

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
Go to End
Author Topic: 1130 Views
  • bebabeba
    Avatar
    Community Member
    192 Posts

    select in admin area Link to this post

    Hi!
    I have a problem whit admin area..
    in the right side of a standard page I see this feald:

    1.Page name
    2.Navigation label
    3.Content

    All of this are text field.
    I must add a select field. What can I write in my getCMSFields functions?
    I use Silverstripe v.2.3.7
    Can you help me please?

    Thanks

  • ayyurek
    Avatar
    Community Member
    41 Posts

    Re: select in admin area Link to this post

    Hi,

    In the Page.php under mysite/code/ folder. First you should add a field where the dropdown's value will be stored.

    public static $db = array (
          'Country' => 'Varchar'
       );

    And then the code for creating the dropdown field.

    function getCMSFields() {
    $fields = parent::getCMSFields();
    $array = array(
    'DE' => 'Germany',
    'FR' => 'France',
    'ES'=> 'Spain'
    );
    $fields->addFieldToTab("Root.Content.Main", new DropdownField(
    'Country',
    'Country',
    $array
    );

        return $fields;
    }

    Don't forget to rebuild the database after these changes with http://yoursitename/dev/build/

  • bebabeba
    Avatar
    Community Member
    192 Posts

    Re: select in admin area Link to this post

    Hi!

    thanks for reply me!!
    Your solution is not correct..

    I try in this way..but there is an error. I see select field but is empty..

    help...

    static $db = array(
          'RubricType' => 'Varchar',
       );

    function getCMSFields() {
          $fields = parent::getCMSFields();
          
          $array = array(
          'DE' => 'Germany',
          'FR' => 'France',
          'ES'=> 'Spain'
          );
          
          
          $fields->addFieldToTab("Root.Content.Main", new DropdownField('RubricType'),'Content',$array);
          
          return $fields;
       }

  • bebabeba
    Avatar
    Community Member
    192 Posts

    Re: select in admin area Link to this post

    I found solution...

    $fields->addFieldToTab("Root.Content.Main", new DropdownField('Country','Country',$array),'Content');

  • ayyurek
    Avatar
    Community Member
    41 Posts

    Re: select in admin area Link to this post

    I am glad you found Yes, the third parameter is the value.

  • bebabeba
    Avatar
    Community Member
    192 Posts

    Re: select in admin area Link to this post

    and if I need a dropdown in which I can select multiple choices?

    1130 Views
Page: 1
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.