Jump to:

23370 Posts in 18160 Topics by 2864 members

General Questions

SilverStripe Forums » General Questions » ListboxField ss3

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: 412 Views
  • merrick_sd
    Avatar
    Community Member
    94 Posts

    ListboxField ss3 Link to this post

    I want to be able to select multiple items from the siteTree, so i could say asssign a banner to multiple pages.

    map() doesn't seem to work anyone know of another way.
    [warning] array_keys() expects parameter 1 to be array object given
    error line 138 ListboxField.php

    line 138 = $hasCommas ....

    i did try explode but that doesn't seem to solve

    why does map(0 work with checkboxes but not listbox

    Checkbox works

        $SiteTreeIDs = SiteTree::get();
       
        if (!empty($SiteTreeIDs)) {
        $map = $SiteTreeIDs->map('ID', 'Title');
        $fields->addFieldToTab('Root.Main',
        new CheckboxSetField(
        $name = "selectedPagesFld",
        $title = "Select Pages",
        $source = $map
        ));
        }

    ListboxField doesn't

    $SiteTreeIDs = SiteTree::get();
       
    if (!empty($SiteTreeIDs)) {
       
        $treemap = $SiteTreeIDs->map('ID', 'Title');
        $mylistboxfield = new ListboxField(
    'selectedPagesFld',
    "Select Pages",
    $source = $treemap,
        $value = ""
        );
       
        $mylistboxfield->setMultiple(true);
       
        $fields->addFieldToTab('Root.Main',$mylistboxfield);
       
        }
       
       
        /* */

    return $fields;

  • IOTI
    Avatar
    Community Member
    189 Posts

    Re: ListboxField ss3 Link to this post

    what about a CheckboxSetField ?

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