Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » canDelete and functions in the constructors FieldList

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 503 Views
  • Chris_Bryer
    Avatar
    Community Member
    35 Posts

    canDelete and functions in the constructors FieldList Link to this post

    For some reason i cant get a dataobject's function canDelete() and canEdit() to work on DataObjectManager. my code works with CTF, but not DOM.

    class MyDataObject extends DataObject{
    ...
    function canDelete(){
          switch($this->Title){
             case 'None':
                return false;
                break;
             default:
                return true;
                break;
          }
          return true;
       }
    }

    also, with ComplexTableFields, i can call a function through the fieldList in the CTF constructor. I can also get values from relationships through dot notation as well. how can i do this with DOM? here's an example with CTF's:

    (in DataObject 'OptionItem')
    function weightWithSymbol(){
          return $this->WeightModifier.' lbs';
       }

    (in CTF constructor)
    $optionSet = new ComplexTableField(
             $this,
             'ProductOptions',
             'OptionItem',
             array(
                'Title' => 'Title',
                'weightWithSymbol' => 'Weight Modifier',
                'PriceModifier' => 'Price Modifier',
                'CodeModifier' => 'Code Modifier',
                'ProductOptionGroup.Title' => 'Option Group'
             ),
             'getCMSFields',
             '',
             'ProductOptionGroupID'
          );

    thanks,
    -Chris

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