We make tools that make websites.

Support Forums

   

FreeForm File/Attachment required field - incorrectly detecting

Rank

Total Posts: 22

Joined: Sep 1, 2009

PM

Ignore

 

I have a file field in the form
i set it as a required field
The submit the form with a file selected
—> Error required field file is empty.

if i make the file field not required it works perfectly???

Bug or am i doing something stupido???

Thanks, N

Avatar
RankRankRankRankRank

Total Posts: 13508

Joined: Oct 18, 2006

PM

Ignore

 

Hi nevsie,

You cannot make the file upload field a required field with Freeform. It’s a pseudo field and not actually an existant field in Freeform, nor can it ever be. That’s why you’re experiencing the behaviour you describe. smile

Your only other option would be to find or come up with a Javascript solution to make it required.

Signature

Avatar
RankRankRank

Total Posts: 111

Joined: Sep 5, 2008

PM

Ignore

 

I’d like to know more about this. Can you explain the pseudo field you describe and why it can’t be required? It seems like a limitation, namely when clients complain their users aren’t attaching *something* that should have accompanied the form. Unfortunately giving them the “it’s a pseudo field, that’s why” answer likely won’t fly. smile

Thanks!

Avatar
RankRankRankRankRank

Total Posts: 13508

Joined: Oct 18, 2006

PM

Ignore

 

Limber,

I’m not sure what else you want me to say. I personally agree, being able to require that field would be great. However, when the required=”” parameter was added into Freeform, it was only coded to check on ACTUAL fields you have in the Fields tab of the Freeform CP. Perhaps the file field was overlooked, or perhaps to get that validated was A LOT more work. I don’t know. smile

Anyway, it is on the Feature Requests list and it’s possible we’ll revisit this in the future.

Signature

Avatar
RankRankRank

Total Posts: 111

Joined: Sep 5, 2008

PM

Ignore

 

Thanks Kelsey. Definitely a bummer for an otherwise terrific tool.

RankRank

Total Posts: 45

Joined: Mar 31, 2009

PM

Ignore

 

limber, use a javascript validation solution and this isn’t a problem. Not only that but you can perform validation without having to leave the page. I’m using Freeform on three forms on http://monderer.com/contact and jquery tools validation. It works great as I get to process forms using Freeform, easily the best solution on the planet for processing forms online, and my validation gets to happen inline. Click submit without filling out any fields to see what I mean.

Rank

Total Posts: 3

Joined: Feb 24, 2009

PM

Ignore

 

A simple way to use javascript to require a file field

Your HTML should look like this

{exp:freeform:form file_upload ="Uploads" required="file"}

File
:
<
input type="file"  id="photoupload" name="file1" value="" class="text" />
<
input id="hiddenfile" type="hidden" name="file" value="" />

<
input type="submit" name="submit" value="Upload"  />
{/exp:freeform:form} 

Your JS should look like this (assuming jQuery)

$("#photoupload").change(function(){
     
$('#hiddenfile').val(this.value);
});