Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Uploadify not showing

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 1123 Views
  • PhillBex
    Avatar
    Community Member
    4 Posts

    Uploadify not showing Link to this post

    Hiya,

    I have installed uploadify and am experiencing a really annoying problem:

    I have a front end form that prompts the user to select an avatar for their profile. The users profile is an extension of the member table, with a has_one relationship for the image as below:

    static $has_one = array(
    "Avatar" => "Image"
       );

    An excerpt of the front end form is as follows:

    new FieldGroup(
       $myAvatar = new FileUploadField('Avatar','Picture')
    ),

    When the form is display, the image field is simply displayed as:

    Picture: (none)

    Without displaying any kind of form field.

    Looking at the source code for the selected area gives:

    <div id="AvatarGroup" class="field fieldgroup nolabel">
    <div class="middleColumn">
    <div class="fieldgroup">
    <div class="fieldgroupField">
    <label for="Form_UpdateForm_Avatar">Picture</label>
    <span id="Form_UpdateForm_Avatar" class="readonly">
    <i>(none)</i>
    </span>
    <input type="hidden" name="Avatar" value="" />
    </div>
    </div>
    </div>
    </div>

    I am sure that I am doing something really stupid but can't seem to figure out what or find anything in the forums.

    Thanks

    Phill

  • UncleCheese
    Avatar
    4085 Posts

    Re: Uploadify not showing Link to this post

    Looks like you're rendering it as readonly?

  • PhillBex
    Avatar
    Community Member
    4 Posts

    Re: Uploadify not showing Link to this post

    Thanks for replying so quickly.

    I wasn't aware that you could render it as read only, how do I make it read/write?

    Phill

  • UncleCheese
    Avatar
    4085 Posts

    Re: Uploadify not showing Link to this post

    Neither did I.. Can you post the code for the form?

  • PhillBex
    Avatar
    Community Member
    4 Posts

    Re: Uploadify not showing Link to this post

    Sorry, should have done this before:

       function UpdateForm() {
          $dateField = new DateField('DateOfBirth','Date of birth');
       $dateField->setConfig('showcalendar', true);
          $dateField->setConfig('dateformat', 'dd/MM/YYYY');

          $myform = new Form($this, "UpdateForm", new FieldSet(
             new FieldGroup(
                 new TextField('FirstName','First name'),
                new TextField('Surname','Last name'),
                new TextField('ScreenName','Screen name'),
                new LiteralField('ScreenNamePrompt','<div class="message"><strong>Remember</strong> this is how members will search for you</div>'),
                new EmailField('Email','Email'),
                new HiddenField('OldEmail',''),
                new PasswordField('Password','Password'),
                new PasswordField('ConfirmPassword','Confirm password')
             ),
             new FieldGroup(
                $myAvatar = new FileUploadField('Avatar','Picture')
             ),
             new FieldGroup(
                new TextField('HouseNumber','House number'),
                new TextField('Street','Street'),
                new TextField('District','District'),
                new TextField('Town','Town'),
                new TextField('County','County'),
                new TextField('PostCode','Postcode'),
                new TextField('Country','Country')
             ),
             new FieldGroup(
                $dateField,
                new DropdownField('Gender','Gender',singleton('Golfer')->dbObject('Gender')->enumValues())
             ),
             new FieldGroup(
                new NumericField('Handicap','Handicap'),
                new HiddenField('OldHandicap',''),
                new DropdownField('WillingToHost','Willing To Host',singleton('Golfer')->dbObject('WillingToHost')->enumValues())
             )
          ), new FieldSet(
             new FormAction('UpdateFormAction', '' )
          ));
          
          if(Session::get('FormData'))
          {
             $myform->loadDataFrom(Session::get('FormData'));
          }
          else
          {
             $Member = Member::CurrentMember();
             if($oldhandicap = DataObject::get_one("Handicap", "GolferID = ".$Member->ID,false,"ID DESC"))
             {
                $Member->Handicap = $oldhandicap->Handicap;
                $Member->OldHandicap = $oldhandicap->Handicap;
             }

             $Member->OldEmail = $Member->Email;
             $Member->Password = "";
           $myform->loadDataFrom($Member->data());
          }
          $myAvatar->allowFolderSelection();
          $myAvatar->uploadOnSubmit();
          $myAvatar->setFileTypes(array('jpg','gif','png'));

          return $myform;
       }

    Look forward to your reply

    Phill

  • UncleCheese
    Avatar
    4085 Posts

    Re: Uploadify not showing Link to this post

    Two things I would try... 1) take it out of the FieldGroup (should work, but you never know). 2) I don't believe allowFolderSelection() is permitted on the frontend, for security reasons.

  • PhillBex
    Avatar
    Community Member
    4 Posts

    Re: Uploadify not showing Link to this post

    It was the FieldGroup!!

    All working now.

    Thanks for your help

    Phill

    1123 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.