21301 Posts in 5735 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 951 Views |
-
select in admin area

22 June 2010 at 1:35am Last edited: 22 June 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.ContentAll 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
-
Re: select in admin area

22 June 2010 at 2:04am Last edited: 22 June 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/
-
Re: select in admin area

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;
} -
Re: select in admin area

22 June 2010 at 2:25am
I found solution...
$fields->addFieldToTab("Root.Content.Main", new DropdownField('Country','Country',$array),'Content');
-
Re: select in admin area

22 June 2010 at 2:31am
I am glad you found
Yes, the third parameter is the value. -
Re: select in admin area

22 June 2010 at 4:05am
and if I need a dropdown in which I can select multiple choices?
| 951 Views | ||
|
Page:
1
|
Go to Top |


