Jump to:

5542 Posts in 1739 Topics by 1225 members

Customising the CMS

SilverStripe Forums » Customising the CMS » ComplexTableField for all entries

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

Page: 1
Go to End
Author Topic: 1676 Views
  • madmaurice
    Avatar
    Community Member
    20 Posts

    ComplexTableField for all entries Link to this post

    I try to use the ComplexTableField in a LeftAndMain to allow the user to edit all entries of one type (dataobject)

    VIPAdmin.php

    <?

    class VIPAdmin extends LeftAndMain {
       static $url_segment = "vip";
       
       static $url_rule = '$Action';
       
       static $menu_title = "VIP Editor";
       
       static $menu_property = 60;

       function getEditor() {
          $editor = new ComplexTableField(
             $this,
             'VIPs',
             'VIP',
             array('Name','Spruch'),
             new FieldSet(
                new TextField('Name'),
                new TextareaField('Spruch')
             )
          );
          
          $editor->setParentClass(false);
          
          return new FieldSet($editor);
       }
       
       function VIPs() {
          return DataObject::get('VIP');
       }
    }

    ?>

    VIP.php

    <?

    class VIP extends DataObject {
       static $db = array(
          "Name" => "Varchar(50)",
          "Spruch" => "Text"
       );
       static $has_one = array(
          "Bild" => "Image"
       );
    }

    ?>

    VIPAdmin_right.ss

    <h1>VIP Editor</h1>

    <% if Editor %>
       $Editor
    <% else %>
       Kein Editor
    <% end_if %>

    if i replace the "return new FieldSet($editor);" with a "return "Hello World!"; " it works. however with the $editor. it shows blank unless the h1-tag

    Thx for your help.

    ps.: sry for my broken english. im from germany

  • madmaurice
    Avatar
    Community Member
    20 Posts

    Re: ComplexTableField for all entries Link to this post

    when just returning the complextablefield i get a (none).
    hope this is helpful

  • madmaurice
    Avatar
    Community Member
    20 Posts

    Re: ComplexTableField for all entries Link to this post

    Got it with this example: http://doc.silverstripe.org/doku.php?id=leftandmain#subclassing

    i needed to use a Form.

    Now i got the "i can't sub-URLs of xyz"-Error with my VIPAdmin Thingy

    VIPAdmin.php

    <?

    class VIPAdmin extends LeftAndMain {
       static $url_segment = "vip";
       
       static $url_rule = '$Action';
       
       static $menu_title = "VIP Editor";
       
       static $menu_property = 60;

       function init() {
          parent::init();
          
          //Requirements::css("sapphire/css/ComplexTableField.css");
       }

       function Editor() {
       
          $editor = new ComplexTableField(
             $this,
             'Editor',
             'VIP',
             array('Name','Spruch'),
             'getCMSFields'
          );
          
          //$editor->setReadOnly(false);
          $editor->setCustomSourceItems( DataObject::get('VIP') );
          
          /*$editor->setPermissions(array(
              'delete',
              'export',
              'print',
              'edit'
          ));*/
          //return $editor;
          return new Form($this,"EditForm",
             new FieldSet(
                new HiddenField('ID', ''),
                $editor
             ),
             new FieldSet(new FormAction('go'))
          );
       }
       
       function VIPs() {
          return new DataObjectSet();
       }
    }

    ?>

    Url i try to access:   http://***/***/admin/vip/EditForm/field/Editor/add
    Error i get:      I can't handle sub-URLs of a VIPAdmin object.

  • aimcom
    Avatar
    Community Member
    8 Posts

    Re: ComplexTableField for all entries Link to this post

    I have a similar problem and I'm still looking for a solution (see http://ssorg.bigbird.silverstripe.com/customising-the-cms/show/292590). How did you solve this?

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