At present, it's not possible to use Content Complete for content types with any Conditional Fields. If a field required by content complete is hidden, the completeness can never reach 100% because the user cannot fill in all required fields. It would be great if it were possible to take fields into account only when they are visible on the form.

I've tried out a solution to this which works for my purposes but haven't rolled a patch yet because I would welcome some input on whether I'm taking the right approach first.

I've modified content_complete_get_data() as shown here:

http://drupalbin.com/20333 (lines 34 - 58).

Comments

pvhee’s picture

Thanks for working on this catfink!

From a first glance the code looks good, some comments:

  • we might also want to include a message to rebuild the content complete cache whenever a value changes in the conditional fields.
  • Not sure if using 'und' (for neutral language) is okay when i18n is used, line 48
auberdjinn’s picture

Thanks for the feedback, pvhee. I'll do some more work on it in the next few days.

auberdjinn’s picture

I've modified this a little to hopefully make it i18n friendly:

http://drupalbin.com/20352
See lines 48 - 53

That should ensure that content complete info is calculated for fields that are visible when viewing the node in the current language.

However, I did notice when testing this that content_complete_get_fields_values() also only uses 'und' to check values, so in effect nodes with any translated fields tagged for content_complete can never be completed anyway.

A separate issue, I guess?

auberdjinn’s picture

Hello,

Well I finally found some time to take another look at this and I have learned how to properly deal with the language issue (I think) by using field_get_items to obtain the values of the dependee fields.

I've attached a patch this time.

I'm not quite sure where to put the message to clear the content complete cache when conditional fields settings are updated: I will have a think and report back on that one shortly.

auberdjinn’s picture

Assigned: Unassigned » auberdjinn
Status: Needs work » Needs review

Sorry, I forgot to change the status in my last comment.

pvhee’s picture

Status: Needs review » Needs work

Thanks catfink for that patch! I've cleaned up a little bit the code style, and committed, sorry for taking so long..
http://drupalcode.org/project/content_complete.git/commit/172325b

In order for this to work well, we still need to have a message appearing to clear caches, we could probably use a hook or a form_alter for that that gets triggered whenever the conditional fields settings are changed.

auberdjinn’s picture

No worries! I've only just noticed that this was committed. I'll take a look at the clear cache message in the next week or two.

josebc’s picture

Issue summary: View changes

Im getting notices on the current dev Notice: Undefined offset: 0 in content_complete_get_data()... this is related to https://www.drupal.org/node/1321262 when the $dependee_field is empty

josebc’s picture

Status: Needs work » Needs review
StatusFileSize
new1.8 KB

this fixed it for me