21309 Posts in 5738 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1858 Views |
-
DropdownField with multiple options

22 June 2010 at 7:19pm
Hi!
in my admin area I create a new field: DropdownField. This allow me to select one option.
Is there a field that allow me to select two or more options? I search something similar in Silverstripe documentations but I found nothing..
can you help me please?thanks!!
-
Re: DropdownField with multiple options

22 June 2010 at 9:16pm
ListboxFields also support multiple selections
http://api.silverstripe.org/trunk/forms/fields-basic/ListboxField.htmltreemultiselectdropdown
http://doc.silverstripe.org/treemultiselectfield -
Re: DropdownField with multiple options

23 June 2010 at 3:57am Last edited: 23 June 2010 4:07am
Hi Willr!
I follow your solution but I have a problem when I save.. 'Error saving content'So I write this to allow 3 options:
static $db = array(
'MultiypleType' => 'Varchar',
);function getCMSFields() {
$fields = parent::getCMSFields();$array = array(
'1' => 'aaa',
'2' => 'bbb',
'3'=> 'ccc'
);$fields->addFieldToTab("Root.Content.Main", new ListboxField('MultiypleType','MultiypleType',$array,$value = '', $size = 4, $multiple=true),'Content');
return $fields;
}what is wrong?
-
Re: DropdownField with multiple options

23 June 2010 at 9:15am
Check firebug (under console), or your console panel in your browser or your error logs to get the actual error message.
-
Re: DropdownField with multiple options

25 June 2010 at 8:55pm
Hi!
my error is the following:
500 Warning: "Array to string conversion" at line 109 of D:\_projects\silverstripe\sapphire\core\model\fieldtypes\DBField.php 419ms
function() {return new ActiveXObject('Microsoft.XMLHTTP')},\n
-
Re: DropdownField with multiple options

15 December 2012 at 6:20pm
Hi here's my example of linking items to it self:
class CatItem extends DataObject {
...
public static $many_many = array(
'LinkedItems' => 'CatItem',
);
...
public function getCMSFields() {
...
$fields->removeByName('LinkedItems');
$fields->insertAfter(
ListboxField::create(
'LinkedItems',
'Linked Items',
CatItem::get()->map()->toArray()
)->setMultiple(true),
'Description'
);
...
}
...
}
It saves item list but I get a notice error to fix this you need to open framework/forms/fields/GridField.php, find a line 665 and replace it with
if($fieldData && isset($fieldData['GridState']) && $fieldData['GridState']) to check if $fieldData['GridState'] is setpublic function handleRequest(SS_HTTPRequest $request, DataModel $model) {
...
if($fieldData && isset($fieldData['GridState']) && $fieldData['GridState'])
...
}
| 1858 Views | ||
|
Page:
1
|
Go to Top |



