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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Uploadify not showing


Go to End


7 Posts   1862 Views

Avatar
PhillBex

Community Member, 6 Posts

6 February 2011 at 11:54pm

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

Avatar
UncleCheese

Forum Moderator, 4102 Posts

7 February 2011 at 7:17am

Looks like you're rendering it as readonly?

Avatar
PhillBex

Community Member, 6 Posts

7 February 2011 at 7:23am

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

Avatar
UncleCheese

Forum Moderator, 4102 Posts

7 February 2011 at 7:51am

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

Avatar
PhillBex

Community Member, 6 Posts

7 February 2011 at 11:46pm

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

Avatar
UncleCheese

Forum Moderator, 4102 Posts

8 February 2011 at 3:45am

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.

Avatar
PhillBex

Community Member, 6 Posts

8 February 2011 at 3:51am

It was the FieldGroup!!

All working now.

Thanks for your help

Phill