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'
);
}