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

images don't attached from the frontend


Go to End


3 Posts   2356 Views

Avatar
Solo

Community Member, 32 Posts

8 April 2010 at 6:05pm

It always says "You can add images once you have saved for the first time." but from backed it is ok. all other fields works properly. Please help!
this is for frontend:

	
function addHotelForm(){                               
    return new Form($this, "addHotelForm",
        new FieldSet(
			new TextField('Title', 'Название'),
            new TextareaField('Description', 'Описание'),
            new TextField('Location', 'Местоположение'),  
			new TextField('Adress', 'Адрес'),
			new TextField('Telefone', 'Телефон'),
			new NumericField('Price', 'Цены'),
			new ImageField('HotelImage', 'Фото Гостиннцы', null, null, null, "assets/Uploads/")
        ),
        new FieldSet(
            new FormAction("doSubmitHotel", "добавить новую гостинницу")
        ), 
		new RequiredFields(
            'Description'
		)	
    );
}

function doSubmitHotel($data, $form){
		$hotel = new Hotel();
		$form->saveInto($hotel);
		$hotel->HotelHolderID = $this->dataRecord->ID;
		$hotel->write();
		$form->sessionMessage(
			'Гостинница успешно добавлена!',
			'good'
		);
		Director::redirectBack();
		return;
}

and for CMS:
	
function getCMSFields() {
	$fields = parent::getCMSFields();
	$HotelTable = new ComplexTableField($this, 'Hotels', 'Hotel');
	$fields->addFieldToTab('Root.Content.Hotels', $HotelTable);
	return $fields;
}

the "assets/Uploads/" don't work too, images saved to Uploads folder

Avatar
Willr

Forum Moderator, 5523 Posts

8 April 2010 at 6:59pm

You should use SimpleImageField for the front end form. The incorrect folder location I think was a bug in 2.3 which should be fixed in 2.4.

Avatar
Solo

Community Member, 32 Posts

9 April 2010 at 3:29pm

Thanks Willr