Sorry for stupid questions, but i m stuck: I make two pages types, the Hotel.php:
<?php
class Hotel extends Page {
static $db = array(
'Title' => 'Varchar(50)',
'Description' => 'Text',
'Location' => 'Text',
'Zvezd' => 'Text',
'Adress' => 'Varchar(100)',
'Telefone' => 'Varchar(100)',
'Price' => 'Text',
);
static $has_one = array(
'Image' => 'Hotel_Image',
'HotelHolder' => 'HotelHolder',
);
static $default_parent = 'HotelHolder';
static $can_be_root = false;
static $singular_name = 'ГоÑтиница';
static $plural_name = 'ГоÑтинницы';
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new TextAreaField('Description', 'ОпиÑание'));
$fields->addFieldToTab('Root.Content.Main', new TextField('Location', 'МеÑтоположение'));
$fields->addFieldToTab('Root.Content.Main', new TextField('Zvezd', 'Кол-во звезд'));
$fields->addFieldToTab('Root.Content.Main', new TextField('Adress', 'ÐдреÑ'));
$fields->addFieldToTab('Root.Content.Main', new TextField('Telefone', 'Телефон'));
$fields->addFieldToTab('Root.Content.Main', new NumericField('Price', 'Цены'));
return $fields;
}
}
class Hotel_Controller extends Page_Controller {
}
?>
and the hotelHolder.php:
<?php
class HotelHolder extends Page {
static $db = array(
);
static $has_one = array(
);
static $has_many = array(
'Hotels' => 'Hotel'
);
static $allowed_children = array('Hotel');
}
class HotelHolder_Controller extends Page_Controller {
function addHotelForm(){
return new Form($this, "addHotelForm",
new FieldSet(
new TextField('Title', 'Ðазвание'),
new TextareaField('Description', 'ОпиÑание'),
new TextField('Location', 'МеÑтоположение'),
new TextField('Zvezd', 'Кол-во звезд'),
new TextField('Adress', 'ÐдреÑ'),
new TextField('Telefone', 'Телефон'),
new NumericField('Price', 'Цены'),
new ImageField('Hotel_Image', 'Фото ГоÑтиннцы')
),
new FieldSet(
new FormAction("doSubmitHotel", "добавить новую гоÑтинницу")
),
new RequiredFields(
'Description'
)
);
}
//Ð¤ÑƒÐ½ÐºÑ†Ð¸Ñ Ð¾Ð±Ñ€Ð°Ð±Ð¾Ñ‚ÐºÐ¸ формы Ð´Ð¾Ð±Ð°Ð²Ð»ÐµÐ½Ð¸Ñ Ð½Ð¾Ð²Ð¾Ð¹ гоÑтинницы
function doSubmitHotel($data, $form){
$hotel = new Hotel();
$form->saveInto($hotel);
$hotel->HotelCategoryID = $this->dataRecord->ID;
$hotel->write();
$form->sessionMessage(
'ГоÑтинница уÑпешно добавлена!',
'good'
);
Director::redirectBack();
return;
}
}
?>
adding new hotel pages is ok in the cms(backend), but, when i tried to add page through frontend - the new pages puts in the root folder not in hotelHolder as i want. What is wrong with my code? Can somebody help?