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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

display calendar on booking engine.


Go to End


2 Posts   981 Views

Avatar
thomas.paulson

Community Member, 107 Posts

28 May 2015 at 5:30am

Edited: 28/05/2015 5:31am

I am developing room booking like below, now i am able to add new 'Rate' via GridFeild, but is it possible in silverstripe cms, to display calenday interface with textbox on each cell, on selected month & year and save the all rate details for particular month & year.

<?php
class Room extends Page {
    /**
     * 
     * @var Array
     */
    private static $db = array(
            'Price' => 'Decimal(19,8)',
            'Currency' => 'Varchar(3)'
    );
	
    private static $has_many = array(
        'Rates' => 'Rate'
    );    

    private static $show_in_sitetree = false;    
    
    // ...
    public function getCMSFields() {
        require_once("forms/Form.php");
        // Get the fields from the parent implementation
        $fields = parent::getCMSFields();    
        
        $fields->addFieldToTab('Root.Main', new PriceField('Price'), 'Content');
        
        //*
        // Create a default configuration for the new GridField, allowing record editing
        $config = GridFieldConfig_RecordEditor::create();
        // Set the names and data for our gridfield columns
        $config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array(
            'Date' => 'Date',
            'Room.Title'=> 'Project' // Retrieve from a has-one relationship
        ));    
        // Create a gridfield to hold the student relationship    
        $ratesField = new GridField(
            'Rates', // Field name
            'Rate', // Field title
            $this->Rates(), // List of all related students
            $config
        );        
        // Create a tab named "Students" and add our field to it
        $fields->addFieldToTab('Root.Rates', $ratesField); 
        //*/
        /*
        $fields->addFieldToTab(
                'Root.Rates',
                FieldGroup::create(
                        TextField::create("Month","Enter month?"),
                        TextField::create("Yes","Enter year?")
                )                
        );
        */
        
        return $fields;
    }    
}
class Booking_Controller extends Page_Controller {
}

<?php
class Rate extends DataObject {
    private static $db = array(
		'Date'=>'Date',
		'Price' => 'Decimal(19,8)'
    );
    private static $has_one = array(
        'Booking' => 'Booking'
    );    
}

Avatar
Pyromanik

Community Member, 419 Posts

28 May 2015 at 8:22pm

D: what is this!?
require_once("forms/Form.php");

It sounds like you want something to enable editing directly in the gridfield without having to go into the record (row) editor, is that right? I can't really follow your explanation :/
You migth be looking for: http://addons.silverstripe.org/add-ons/ajshort/silverstripe-gridfieldextensions

If you're simply wondering how to get a calendar to pop up on each datefield, you set it on the datefield's (instance) config.
http://api.silverstripe.org/3.1/class-DateField.html