Jump to:

10979 Posts in 2722 Topics by 1815 members

All other Modules

SilverStripe Forums » All other Modules » extending DataExtension

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 375 Views
  • Riposte
    Avatar
    Community Member
    10 Posts

    extending DataExtension Link to this post

    Hi All
    I'm not exactly top shelf when it comes to the coding stuff and could use a bit of help with where to look for the error causing my problem.
    I have made a minor extension to the CalendarDateTime Class to add three new fields:
    New file MeetDetails.php in mysite/code folder:
    <?php

    class MeetDetails extends DataExtension
    {
    private static $db = array(
    'Location' => 'Text',
    'Entries Close' => 'Date',
    'No Times' => 'Boolean'
    );

    private static $has_one = array (
    'Event' => 'CalendarEvent'
    );

    public function updateCMSFields(FieldList $fields) {

    $fields->push(new TextField('Location', 'Location'));
    $fields->push(new DateField('Entries Close', 'Date Entries Close'));
    $fields->push(new CheckboxField('No Times', 'No Times Allowed'));
    }
    }

    and added;
    Object::add_extension('CalendarDateTime', 'MeetDetails');

    to my _config.php file.

    Ran dev/build?flush=1 and new fields appear in database and in CMS as expected.

    The problem is only the 'Location" textfield will save any data. With the other two you can set them all you like but they wont save anything.
    Pushing the 'Save" button reloads the page but the two fields reset to blank.

    Where should I start looking to solve this?

    Any help appreciated.

  • Riposte
    Avatar
    Community Member
    10 Posts

    Re: extending DataExtension Link to this post

    Still havn't solved this - have I logged it in the right part of the forum?
    A advice on how to debug this sort of problem even?

  • Pigeon
    Avatar
    Community Member
    243 Posts

    Re: extending DataExtension Link to this post

    Try removing the spaces from the DB field names?

  • Riposte
    Avatar
    Community Member
    10 Posts

    Re: extending DataExtension Link to this post

    Thanks Pigeon - that sorted it.
    New it would be something simple that would probably highlight my noobishness (is that a word?).

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