Now, module has this smooth flow:
- user type in for example node title
- user hit save
- module check if it is original - if not, display error message

Better workflow is to check originality of field before node is submitted using ajax:
- as soon as user leave field (focus off), ajax will check if field is uniqe.

You can take code inspiration from module Username originality AJAX check.

I found this in Username originality AJAX check issues: https://drupal.org/node/1399360 - Reproduce the same functionality as username check on fields

Comments

reubenavery’s picture

Assigned: Unassigned » reubenavery

I'll take this on. Patch to come shortly.

reubenavery’s picture

Status: Active » Needs review
StatusFileSize
new10.84 KB

And here we go. Note there is a new setting field on the content type's unique field settings pane which specifies the field onto which we attach the AJAX call.

mrvee’s picture

Awesome, thank you reubidium, this worked great for me.

zilla’s picture

very cool - will this get rolled in a dev release soon?

zilla’s picture

bump: any idea if this will make it to a dev release? seems that last update was 2011

zilla’s picture

Issue summary: View changes

dsf

Coupon Code Swap’s picture

The patch in #2 works quite well. I have a couple of suggestions.

1. It would be good to only do checking if a field has not been left empty. I have two fields I use in combination to validate uniqueness. The way it is now, if one field is filled and the other field is left empty and loses focus, the error message is displayed for every node that has been posted with the combination, regardless of uniqueness.

2. By default, it would be better to place the error message in the usual Drupal $messages area, rather than on the field. Having it set on the field causes other inputs in the form to jump around in akward ways when the message is displayed. If this were configurable for either $messages area or field, it would be ideal.

kopeboy’s picture

Priority: Normal » Major
Issue summary: View changes

Can we have an update on this please? :)

I am not sure I can help cause I am not a developer, but this is a very important feature!

About the latest suggestions:

  1. Yeah I agree totally
  2. Not sure, it can be much better so have it on the field so people will notice as soon as they fill it.. Isn't that just a problem of styling with CSS?
joshbudda’s picture

LOVE this patch so thank you for that!

I'm having an issue where I need ajax to validate more than one field. Is that possible?

In other words, rather than having a select list that can only select one field for "Attach AJAX preview to field" it would be amazing to have checkboxes so the user can select multiple fields.

hockey2112’s picture

Trying to implement this patch, but I am unclear on this part:

diff --git a/sites/all/modules/custom/iv_persona_helper/iv_persona_edit.js b/sites/all/modules/custom/iv_persona_helper/iv_persona_edit.js
index cdb38cb..b98c85f 100644
--- a/sites/all/modules/custom/iv_persona_helper/iv_persona_edit.js
+++ b/sites/all/modules/custom/iv_persona_helper/iv_persona_edit.js
@@ -10,7 +10,11 @@
},

process: function(context) {
- if ($(context).val() == 'sponsor') {
+ if ($(context).val() == '_none') {
+ $('#node_persona_form_group_sponsors').hide();
+ $('#node_persona_form_group_social_media').hide();
+ }
+ else if ($(context).val() == 'sponsor') {
$('#node_persona_form_group_sponsors').show();
$('#node_persona_form_group_social_media').hide();
}

Is this a new file that needs to be added? If not, where can I find this "iv_persona_helper" custom module?

hockey2112’s picture

I added this patch (minus the "iv_persona_helper" part) to unique_field-7.x-1.0-rc1, but it is not adding the AJAX effect. I am using the "Seven" admin theme, and also tested it with Garland.

Realeiko’s picture

@hockey2112, I've done the same process, and it works like a charm. Be aware that it needs a little configuration in the content type:

Note there is a new setting field on the content type's unique field settings pane which specifies the field onto which we attach the AJAX call.

By default it is disabled ;)

+1 to add an option to choose to report to message area instead to a field attach.

And any idea if this will make it to a dev release?

By the way, this module is freaking awesome usefull! And with this patch is a the ultimate productivity booster! Good job guys! Thank you!

astonvictor’s picture

Status: Needs review » Closed (outdated)

I'm closing it because the issue was created a long time ago without any further steps.

if you still need it then raise a new one.
thanks