Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Checkboxes in popup only stored on second time save

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 2349 Views
  • Laurie
    Community Member
    21 Posts

    Re: Checkboxes in popup only stored on second time save Link to this post

    I'm running into the same issue (using 2.4.0)...code below.

    I'm trying to associate a highlight (think news item) with one or more practice areas (like economics, education, gender, etc.). So, for example, if we were to win a contract dealing with gender issues in education, we might post a highlight on both our gender and education practice area pages.

    In addition, three other interesting things are happening with the popup...which might (or might not) be related the same problem.

    1. From the table of highlights, the edit link works (i.e., brings up the popup and lets the item be edited) but the show link does not. The show link returns a 500 error with the following written to the SilverStripe log:

    [02-Jun-2010 05:37:27] Warning at \sapphire\thirdparty\Zend\Locale\Format.php line 692: iconv_strpos() expects parameter 2 to be string, unknown given (http://www.devtechsys.mirror/admin/EditForm/field/HomePageHighlights/item/6/show?ajax=1)

    2. When a highlight is edited and saved, the green confirmation bar at the top shows the ID of the item rather than the headline. For example, 'Saved Highlight "#1" (Close Popup)' rather than 'Saved Highlight "DevTech Awarded Senegal Contract" (Close Popup)'. Is there a place to set what field is used as essentially the title for the item?

    3. $sourceFilter and $sourceSort don't seem to be working properly...see http://silverstripe.org/customising-the-cms/show/285556#post285556 for a more detailed description of that problem.



    class Highlight extends DataObject {   

       static $singular_name = 'Highlight';
       static $plural_name = 'Highlights';
       static $db = array (
          'Headline' => 'Varchar',
          'Blurb' => 'Text',
          'Link' => 'Varchar',
          'StartDate' => 'Date',
          'EndDate' => 'Date',
          'HomePage' => 'Boolean'

       static $many_many = array (
       function getCMSFields() {
          $practiceAreaList = DataObject::get('PracticeArea')->toDropdownMap('ID', 'AreaName');

          $fields = new FieldSet (
             new TextField('Headline', 'Headline'),
             new TextareaField('Blurb', 'Blurb'),
             new TextField('Link', 'Link'),
             new DateField('StartDate', 'Start Date'),
             new DateField('EndDate', 'End Date'),
             new CheckboxField('HomePage', 'Include on home page?'),
             new CheckboxSetField('PracticeAreas', 'Include this highlight on the following practice area pages:', $practiceAreaList)
          return $fields;

    class PracticeArea extends DataObject {   

       static $singular_name = 'Practice Area';
       static $plural_name = 'Practice Areas';

       static $db = array (
          'AreaName' => 'Varchar'
       static $field_names = array (
          'AreaName' => 'Practice Area'
       static $field_types = array (
          'AreaName' => 'TextField'
       static $belongs_many_many = array (
          'Highlights' => 'Highlight'

    class HomePage extends Page {
       static $db = array (
       function getCMSFields() {
          $fields = parent::getCMSFields();
          $highlightsTable = new ComplexTableField (
             $controller = $this,
             $name = 'HomePageHighlights',
             $sourceClass = 'Highlight',
             $fieldList = array(
                'StartDate'=>'Start Date',
          $fields -> addFieldToTab('Root.Content.Highlights', $highlightsTable);
          return $fields;
    class HomePage_Controller extends Page_Controller {
       function HomePageHighlights() {
          $now = date('Y-m-d');
          $where = "startDate <= '$now' AND endDate > '$now' AND homePage = 1";
          return DataObject::get('Highlight', $where, 'startDate DESC');

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