Jump to:

23471 Posts in 18941 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » images don't attached from the frontend

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

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

Page: 1
Go to End
Author Topic: 1505 Views
  • Solo
    Avatar
    Community Member
    32 Posts

    images don't attached from the frontend Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: images don't attached from the frontend Link to this post

    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.

  • Solo
    Avatar
    Community Member
    32 Posts

    Re: images don't attached from the frontend Link to this post

    Thanks Willr

    1505 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.