Jump to:

7913 Posts in 1355 Topics by 930 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Preview: DataObjectManager module

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w

Go to End
Author Topic: 54348 Views
  • drye
    Avatar
    Community Member
    49 Posts

    Re: Preview: DataObjectManager module Link to this post

    UncleCheese, Have you ever thought about modifying the popup to have the save button on the bottom next to the close button? Just a random thought.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    Good idea, but unfortunately, not likely to happen. The save button needs to be in the iframe and the close button needs to be on the popup window itself. The next enhancement I make to the FileDataObjectManager, and by transference, the ImageGallery, is to add a "Stop Captioning" button next to save that will give the users a more intuitive way to stop the post-upload walkthrough if they wish.

  • drye
    Avatar
    Community Member
    49 Posts

    Re: Preview: DataObjectManager module Link to this post

    Uncle Cheese, Noticed that a boolean displays in the table as a 1 or 0. Could this be a checkbox instead? Possibly even editable from the table view?

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    That's true with any TableField. Make sure you build a custom getter.

    static $db = array (
    'MyBool' => 'Boolean'
    )

    public function getMyBool()
    {
    return $this->MyBool ? "Yes" : "No";
    }

  • drye
    Avatar
    Community Member
    49 Posts

    Re: Preview: DataObjectManager module Link to this post

    Thanks, Actually I was already trying something like this:

       public function getPublish()
       {
          $field = new CheckboxField('Publish','Publish this content?',$this); [EDIT]
          $field->useLabelLeft(false);
          return $field;
       }

    But it only displays the checkbox, it doesn't accept the changes...
    http://pastie.org/415959

  • drye
    Avatar
    Community Member
    49 Posts

    Re: Preview: DataObjectManager module Link to this post

    ok, well I got it to work, learned that you can't use $this->MyBoolean inside a getMyBoolean, had to change function to getMyBooleanField.

    Now that seems to work for viewing, but the edits don't persist. Any Ideas?

    http://pastie.org/415982

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    You're not understanding how a custom getter works.

    $manager = new DataObjectManager(
    $this,
    'MyDataObjects',
    'MyDataObject',
    array('Title' => 'Title, 'Published' => 'Published')
    );

    class MyDataObject extends DataObject
    {
    static $db = array (
    'Title' => 'Varchar(100)',
    'Published' => 'Boolean'
    );

    public function getPublished()
    {
    return $this->Published ? "Published" : "Unpublished";
    }
    }

    That's all you need. When drawing the values for each record, SS first looks for a function named get[PropertyName]. If that function exists, it returns the value of that function. Otherwise, it just returns the value of PropertyName, which in the case of a boolean, is a 1 or 0.

  • drye
    Avatar
    Community Member
    49 Posts

    Re: Preview: DataObjectManager module Link to this post

    I appreciate your comments, however I do understand how the get functions work. Your code will not work, you get an error. $this->Published is undefined, by asking in the IRC channel I found out that it was because that basically creates infinite recursion. You are calling the get function you just defined within it's self by asking for $this->Published. So I had to write a differently named getter to get the field I wanted, I want an ACTUAL check box field so I need to return a field. Well my code achieves this portion of my question. The open question I have is it possible to directly edit the data from the table and not within the light box? I have a checkbox, and I can change it's state from the table, but the changes do not persist. On a similar note, what if you wanted the text to be editable from the table, is this possible?

    Again, I appreciate your help! Thanks again!

    54348 Views
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.