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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Checkboxes in popup only stored on second time save


Go to End
Reply


9 Posts   2512 Views

Avatar
Laurie

Community Member, 21 Posts

3 June 2010 at 9:55am

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.

Thanks.

Cheers,
Laurie

<?php
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 (
      'PracticeAreas'=>'PracticeArea'
   );
   
   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;
   }
}
?>

<?php
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'
   );
}
?>

<?php
class HomePage extends Page {
   static $db = array (
   );
   
   function getCMSFields() {
      $fields = parent::getCMSFields();
      $fields->removeFieldFromTab('Root.Content.Main','BoxTitle');
      $fields->removeFieldFromTab('Root.Content.Main','BoxContent');
      $highlightsTable = new ComplexTableField (
         $controller = $this,
         $name = 'HomePageHighlights',
         $sourceClass = 'Highlight',
         $fieldList = array(
            'Headline'=>'Headline',
            'StartDate'=>'Start Date',
            'EndDate'=>'EndDate'
         )
      );
      $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');
   }
}
?>

Go to Top