Hi,

This site is for consultants, they review CV's if approved, approve and account that sends an email to the user that he is approved and he can use the site username and password.

To do this, content profile is the best module to use.

the following steps were done

1. Content type resume created, enabled as content profile
2. Filefield and appear in user registration enabled and REQUIRED option selected

everything is fine, some users are registering with CV's and some forget to CLICK ON UPLOAD. and gets registered without a prompt from system that they have forgot to press UPLOAD.

Please help me we are losing customers, i know nothing more than enabling and disabling.

Thanks
Danish

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chrism2671’s picture

Version: 6.x-1.0-beta3 » 6.x-1.0-beta4

I can confirm this behaviour on beta 4.

I performed the test by clicking save on the node without clicking the upload button. The expected behaviour is to upload on node save without having to explicitly click on the upload button.

I have tested this using

  • Just the vanilla form ("Add Content") and it works fine.
  • The edit profile form provided by content profile - works fine.
  • The user registration page provided by content profile - broken.

It is worth noting that this worked correctly under Drupal 5.

It is unclear whether this is being caused by content profile, CCK, filefield or node.

Any thoughts (or requests for further info) very much appreciated!

Danish- Did you resolve this issue?

macrodesign’s picture

see Chrism,

I changed the workflow. using logintoboggan module. now users are login as soon as they create the account and directed to create resume page, on this page they create their resume and upload 1-2 files as required and it is working fine. But i failed to do it on 1 page i.e registration + resume.

vivianspencer’s picture

I can also confirm this bug, if you don't press the upload button during registration the file wont upload

chrism2671’s picture

I had a developer look at it for a morning and he says that this is because the form handler on the user form is different from the form handler on the CCK form. He says that the one for the user/nodeprofile is much simpler, and while it can handle all the basic CCK widgets, it doesn't handle the filefield properly.

Can anyone make sense of this?

C.

quicksketch’s picture

Category: support » bug

Marked #519726: FileField and Content Profile and #529768: Filefield doesn't work properly on nodeprofile as duplicates. This is a bug with Content Profile (or maybe an unwritten "feature") and not with FileField, since FileField is meant to work with CCK and Content Profile uses a bit of a hack to the user registration form since CCK wasn't actually meant to provide this sort of functionality.

fago’s picture

I never had a look at it or tried it.

From the README:
* Putting file uploads on the registration form is not supported and probably won't work right.

chrism2671’s picture

Is it something we could look at? Do you think it might be hard to resolve? I don't mind taking some time to look at it, if I had some pointers in the right direction.

fago’s picture

Probably just something is missing form $form that filefield needs.

chrism2671’s picture

I would be willing to sponsor $50 for the fix of this problem.

pecker’s picture

I thought I was doing something wrong when I couldn't get this to work.

I don't know if I'm relieved or frustrated that it's not a simple fix.

+1 for getting this as a feature.

chrism2671’s picture

I'm going to increase my bounty to $70 if fixed in the next 2 weeks. It would be very much appreciated!

albert24’s picture

FileSize
3.75 KB

Hi chrism2671!

I think I have come up with a fix for this problem. Well, it's technically more of a "hack" than a fix.

You're right when you said...

...this is because the form handler on the user form is different from the form handler on the CCK form...

So I decided to just approach this problem in a very straightforward manner.

The expected behaviour is to upload on node save without having to explicitly click on the upload button.

Since you really just want to prevent users from submitting the form without first hitting the upload button, then I decided to address it by auto-uploading the selected file right after the user selects a file.

I added some jquery code to handle this. I added it directly to the filefield.js file inside the filefield module directory.

What I did...

I added the following code. (Please refer to attached file to find out where I inserted the following code).

// Auto-Press upload button
$(this).parent().find('input.form-submit').mousedown();
        
// Disable main submit button while uploading...
$('#edit-submit').attr('disabled', 'disabled');

What this does...

1. I added some jquery code to auto-press the upload button when the user selects a valid file. I got the idea from this post.

2. I added another piece of code to disable the submit button while it is uploading. This is to prevent the user from prematurely submitting the form when the file hasn't been successfully uploaded yet.

More code...

function checkIfUploaded() {
  
  if ( $("div.filefield-file").length > 0 ) {
    // Enable submit button
    $('#edit-submit').attr('disabled', '');
  }
  else {
    
    setTimeout("checkIfUploaded()", 1000);
  }  
  return;  
}

What this does...

It's a function that checks every 1 second if the upload widget has already been replaced with a preview widget (which means that it's done uploading), and if yes, enable the main submit button so that the user can submit the form.

There are some anticipated side-effects to this hack. One is that this will affect all filefield upload widgets of your entire site. They will all have the auto-upload functionality. This shouldn't be a problem, since it's actually what you really expect it to do, right?

The expected behaviour is to upload on node save without having to explicitly click on the upload button.

Another side-effect is that this will only work on the current module version (filefield-6.x-3.1). And it might not work properly (or might not even work at all) on future upgrades of the module, since this is a hack. But this shouldn't be a problem if you are content with how filefield currently performs. You can just wait until filefield makes the feature you want built-in, and then you can make the upgrade.

It works in IE 7, Opera, Firefox, and Chrome.

I used filefield-6.x-3.1.

Directions:

1. Replace the filefield.js file in your filefield module directory with the attached file (Make sure that you rename the file to filefield.js).

That's it.

Should you have any questions or clarifications, don't hesitate to let me know. Thanks! Enjoy!

If you are satisfied with the quick fix, my paypal email is albertpadin(at)gmail(dot)com. The bounty will be greatly appreciated!

albert24’s picture

FileSize
3.62 KB

Hi chrism2671!

I made a change in the checkIfUploaded() function. The change will make the hack work even in image file uploads using the filefield widget. I uploaded the modified custom_filefield.txt (please refer to attachment).

function checkIfUploaded() {
  
  if ( $("div.widget-preview").length > 0 ) {
    // Enable submit button
    $('#edit-submit').attr('disabled', '');
  }
  else {
    
    setTimeout("checkIfUploaded()", 1000);
  }  
  return;  
}

PLEASE USE THE CURRENT ATTACHMENT. You can disregard the previous one. Thank you!

I hope this has helped. Enjoy!

Jon Pugh’s picture

Status: Active » Needs review
FileSize
928 bytes

The problem is this, thanks to firebug:

"Form contains a file input, but is missing method=POST and enctype=multipart/form-data on the form. The file will not be sent."

Attached is a patch that detects if the enctype is set in a node form, then sets it in the user registration $form.

fago’s picture

Status: Needs review » Fixed

ah yep, of course the enctype has to be set. I've committed that fix, thanks.

I set the issue to fixed for now. I don't know if filefield works now, it might - feel free to reopen if it doesn't. Anyway I'm happy to add in (proper) fixes for that, but it's still "officially" not supported.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

sabyrodrigues’s picture

sabyrodrigues’s picture

Priority: Normal » Critical
Status: Closed (fixed) » Needs work

Hi,

The hack provided at http://drupal.org/node/451654#comment-2029388 was really effective if people forget to click the upload button as it auto uploads the Browsed content.

I am using Content profile to expose fields at Registration which has a compulsory Upload Resume Field with an red (*) marking it as compulsory Field in Registration display.

Unlike other Compulsory fields if left empty displays a warning message that the field is required . this ain't working with the File Field Compulsory Upload Button Field exposed in registration.

Users Can Skip this field and Complete the registrations. I am too loosing out on Resumes due to this problem. Can Anybody having knowledge with the validation During registration check for the same.

Regards

iaminawe’s picture

I replaced the js file and applied the patch.

This no longer seems to work with Filefield 6.x-3 and Content Profile 6.x-1.0-beta4

I have two required image filefields on my registration form and if I leave them empty, I can still submit the form without any validation warning.

If I choose browse and then dont choose upload and save the form, the images are not added or uploaded

If I choose browse and then upload for each and I submit the form they are still not attached

Any help with this would be greatly appreciated.

Thanks
Gregg

iaminawe’s picture

Sorry i was wrong, it does work to upload the images but it does not respect the fact that the upload fields are required and so allows users to register without attaching any images.

bneel’s picture

I have the same problem with Filefield 6.x-3 and Content Profile 6.x-1.0-beta4.
Thanks
Ben

TwoD’s picture

Version: 6.x-1.0 » 6.x-1.0-beta4

I encountered the same problem on a client's site and found that it happens because content_profile_registration module ignores the form-level #validate callbacks set on each node form. ImageField and FileField won't run their filefield_node_form_validate() callback because of this.

As a fix I added the below code to content_profile_registration.module
in content_profile_registration_add_profile_form() around line 160.

  // Add form level validators but skip the first one (node-form-specific).
  array_shift($form_add['#validate']);
  foreach ($form_add['#validate'] as $callback) {
    $form['#validate'][] = $callback;
  }

That is just after merging in the fields from the content type.
So far I've not seen any side effects of this, but it's only been tested with a single content type adding file/image fields to the registration page.
I would have thought adding the #submit handlers would be required as well (I know at least upload module uses one), but it wasn't needed in our case.

If people find this useful (and it's not just plain wrong to do it this way) I'd be happy to provide a proper patch, but I'm new to these modules so I've probably missed something.
EDIT: Fixed typo in PHP tag causing it to be filtered out.

MattClark’s picture

Version: 6.x-1.0-beta4 » 6.x-1.0

Hi TwoD,
I am also facing the same problem. Your solution sounds promising, but I couldn't find the code you mentioned anywhere.. could you please post your suggested fix again?

Regards,

nedwardss’s picture

Version: 6.x-1.0-beta4 » 6.x-1.0

This worked well for me. TwoD's code is added in the content_profile/modules/content_profile_registration.module file as was said, around line 160. I put it after $form += $form_add; and before if (!isset($form['#content_profile_weights'])) {

I haven't experienced any side effects either, but until there is a patch applied, this seems to work for me.

Thanks TwoD!

fago’s picture

Priority: Critical » Normal

As filefields are not supported on the registration page (see README) turning priority down to normal.

JThan’s picture

The filefield validates now, but says the file is needed even when it was uploaded.
Before: You could save the profile without uploading a file
After: You cannot save the profile even if you include a file

EDIT: Fixed Typo

JThan’s picture

I followed this and found filefield_node_form_validate($form, &$form_state) in filefield_widget.inc (Filefield 3.7). I had to change that function to make this working. I added a ticket there to ask if my changes do any harm (I bet they will): http://drupal.org/node/917642

So, this is working for me now, but more tests will be done this week. If I dont report back, everything went fine :)

EDIT: To be clear: I got this working with both TwoD's Code and my hack of filefield module.

jannol’s picture

I use content profile 6.x-1.0

I added the code above and it works fine without anything else. Thx

YK85’s picture

scalp’s picture

I added this patch to another issue, but it was suggested that I add it here too. This will cause filefields to be truly required on registration if they're set to be. It works well for me, hopefully others will find it useful.

seakayjay’s picture

#30 patch works fine with me. It is indeed pretty useful. Thank you,scalp.

obrienmd’s picture

Status: Needs work » Reviewed & tested by the community

#30 patch works great here as well.

fago’s picture

Category: bug » task
Status: Reviewed & tested by the community » Active

Re-categorizing due to #25.

grahamvalue’s picture

From http://drupal.org/node/836332#comment-3744388

Here's a sample solution in the meantime that works (modify for files accordingly)

function hook_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL)
{
if($node->type == 'profile')
{
if ($node->field_profpic[0]['filesize'] == 0)
form_set_error('field_profpic', t('Please upload a profile picture.'));

}
}

kirankumar_k’s picture

Title: Filefield upload validation during registration » Filefield upload during registration

Hi All,

How can i add a file upload field in registration form to upload user his photo or resume, can anybody please help me in this issue asap...

Thanks inadvance...

----Kira............

guntherdevisch’s picture

Hi all,

Looks nice, but i'm having problems showing the filefield on my registration form. I'm using AAR for 2 roles; each has a separate registration path (using "Assign from Path"). That's working fine, but i also have a content profile field (filefield) that's activated in my content profile settings ("Use on Auto Assign Role paths") for one of my registration pages. The problem is that i'm not seeing my content profile field in my registration form.

Can someone help me?

-> FIXED <- I had to enable the module "Content Profile User Registration"

I'm also using LoginToboggan.

Thanks for your time,
Gunther

kirankumar_k’s picture

Hi all,

I want to display user profile image in all pages in menu block and i am using 'zeropoint' theme, but am unable to do that. Can any body please help in this issue asap.

Thanks inadvance,

---Kira________

aleada’s picture

Reply to #30
why this patch is not applied on the latest release of content_profile module?
What will be happen on the next releases? We should apply the patch again and again?

guntherdevisch’s picture

I don't know if it is allready mentioned, but an important note for #30 is that you must apply the patch, before you install the module :) I'm also curious if this patch will be applied on the next release.

Great patch, thanks!

Greets,
Gunther

scalp’s picture

I'm glad to hear that the patch is working for people. I don't know anything about getting it committed though. Does anyone know if there's something I need to do to get it committed or do the maintainers just pick up patches from the issues and commit them?

scalp’s picture

Status: Active » Needs review
jrstmartin’s picture

The suggested code in #22 works against 6.x-1.x-dev for me. I'm not using it for Filefield though. I'm using it for a free tagging Taxonomy with the Taxonomy Limit module applied, so users can't inundate the site with bunk tags.

The issue was that Taxonomy Limit module wasn't allowed to add its #validate function callback. It works now. Fully tested. No issues like those mentioned in #26. Thanks TwoD!

Attached patch for convenience.