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

select in admin area


Reply


6 Posts   1174 Views

Avatar
bebabeba

Community Member, 193 Posts

22 June 2010 at 1:35am

Edited: 22/06/2010 1:38am

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

Avatar
ayyurek

Community Member, 41 Posts

22 June 2010 at 2:04am

Edited: 22/06/2010 2:07am

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/

Avatar
bebabeba

Community Member, 193 Posts

22 June 2010 at 2:19am

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;
   }

Avatar
bebabeba

Community Member, 193 Posts

22 June 2010 at 2:25am

I found solution...

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

Avatar
ayyurek

Community Member, 41 Posts

22 June 2010 at 2:31am

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

Avatar
bebabeba

Community Member, 193 Posts

22 June 2010 at 4:05am

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