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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Save button disabled


Go to End


3 Posts   1238 Views

Avatar
cmc

Community Member, 33 Posts

14 March 2012 at 12:29pm

I have two similar DOMs for different pages. Both have nested FileDataObjectManagers. In one of them the "Save" button is disabled in the popup once a file has been added. The other works fine, file or no file.

In the broken Popup, form data can be saved by putting one's cursor in a textfield and pressing return.

As far as I can tell, the problem is that the "</form>" tag is being inserted before the "Save" button div in the broken Popup, and after the "Save" button div in the working Popup.

Any ideas?

Avatar
UncleCheese

Forum Moderator, 4102 Posts

16 March 2012 at 2:11pm

Can you post your code and/or a screenshot?

---------------
Silverstripe tips, tutorials, screencasts, and more. http://www.leftandmain.com

Avatar
cmc

Community Member, 33 Posts

21 March 2012 at 12:05pm

I don't see a way to add an image, but here is the code.

CourseAdvertisement class - this is the main class for the DOM popup that has the "Save" button that doesn't work.

class CourseAdvertisement extends DataObject {
    public static $db = array (
        'CourseName' => 'Text',
        'CourseDescription'=> 'HTMLText',
        'CourseVideo' => 'HTMLText',
        'CourseImageAltText' => 'Text',
        'CourseAdditionalDescription' => 'HTMLText'
        
    );
    
    static $has_one = array (
        'CourseImage' => 'Image',
        'CourseSalesPage' => 'CourseSalesPage'
    );
    
    static $has_many = array (        
        'CourseOptions' => 'CourseAdvertisementItem',
        'Files' =>'CourseAdvertisementFile'
    );
    
    
    public function getCMSFields() {
        $files = new FileDataObjectManager (
                $this,
                'Files',
                'CourseAdvertisementFile',
                'File',
                array(
                    'FileName' => 'Name',
                    'FileDescription' => 'Description'
                )
            );
		$files->allowUploadFolderSelection = false;
		$files->setUploadFolder('Uploads/CourseSalesFiles');
                $files->setAddTitle('File');
        
        $buynowButtons = new DataObjectManager (
                $this,
                'CourseOptions',
                'CourseAdvertisementItem',
                array (
                    'ItemDescription' => 'Description',
                    'ItemPrice' => 'Price',
                    'ItemButtonCode' => 'Buy Now Button Code'
                )
            );
        $buynowButtons->setAddTitle('Sales Option');
        
        return new FieldSet(
            new TextField('CourseName', 'Name'),
            new SimpleHTMLEditorField('CourseDescription', 'Description'),
            new TextField('CourseVideo', 'Video Embed Code (Format: [Vimeo id= width=360 height=210]Description[/Vimeo])', '[Vimeo id= width=360 height=210]Description[/Vimeo]'),
            new ImageField('CourseImage', 'Image', Null, Null, Null, 'Uploads/CourseSalesImages'),
            new TextField('CourseImageAltText', 'Alternate Text for Image'),
            new SimpleHTMLEditorField('CourseAdditionalDescription', 'Additional Description (below small image on right)'),
            $buynowButtons,
            $files
        );
        
    }
}

CourseAdvertisementItem class - nested DOM

class CourseAdvertisementItem extends SalesItem {
    public static $db = array (
    );
    
    static $has_one = array (
        "CourseAdvertisement" => "CourseAdvertisement"
    );
    
}

SalesItem class - nested DOM.

class SalesItem extends DataObject {
    public static $db = array (
        'ItemDescription' => 'HTMLText',
        'ItemPrice' => 'Text',
        'ItemButtonCode' => 'HTMLText'
    );
    
    static $has_one = array (
    );
    
    public function getCMSFields() {
        return new FieldSet(
            new TextareaField('ItemDescription', 'Description'),
            new TextField('ItemPrice', 'Price'),
            new TextField('ItemButtonCode', 'ButtonCode')
        );
    }
}

CourseAdvertisementFile class - Another nested DOM. Save button stops functioning once a file has been added.

class CourseAdvertisementFile extends PageFile {
    public static $db = array (
    );
    
    static $has_one = array (
        'CourseAdvertisement' => 'CourseAdvertisement'
    );

}

PageFile class

class PageFile extends DataObject {
    public static $db = array (
        'FileName' => 'Text',
        'FileDescription' => "Text"
    );
    
    static $has_one = array (
        'File' => 'File'
    );
    
    public function getCMSFields() {
        return new FieldSet(
            new TextField('FileName', 'File Name'),
            new FileIFrameField('File'),
            new TextareaField('FileDescription', 'File Description')
        );
    }
}