My node configurated to be terms of use is in zh-hans language (Chineese). In user_registration_form_alter, we try to get the body with $node->body[$node->language]. But in the table field_data_body, language related to the body of my node is declared as undefined. I try several possibilities with translation module. Even if I have a translated node for my terms_of_use, the body is always saved as undefined language in database. I can't find an example where the body is saved as $node->language in the database (unless my node is in undefined language).

Notice: Undefined index: zh-hans in terms_of_use_form_user_register_form_alter() (line 88 of /var/www/deployments/instance_s3/sites/all/modules/contrib/terms_of_use/terms_of_use.module)

Comments

vbouchet’s picture

guillaumev’s picture

Status: Active » Reviewed & tested by the community

Exact same problem here. I can confirm the patch is working. Would love to see this committed :-)

Québec’s picture

Hi,

patch is working (my first patch ever!). Would love to see this committed églament! :-)

R.

semiaddict’s picture

Works for me as well, and would indeed love to see it committed.

dsdeiz’s picture

Works here as well.

kars-t’s picture

Status: Reviewed & tested by the community » Needs work

Hi

I fear we need some other solution for this. The node always has somekind of language. In this case it is "und" = "undefined". But this isn't always the case. And you probably use field translation or at least the i18n module?

Always using LANGUAGE_NONE which actually is "und" can give us problems again. There should be a more robust API call to get the data from $node->body. I don't thing it is field_get_items but maybe it works. Please check this and if possible reroll the patch.

dsdeiz’s picture

StatusFileSize
new807 bytes

Hi, patch attached.

dsdeiz’s picture

Status: Needs work » Needs review
kars-t’s picture

Status: Needs review » Fixed

Hi

Thanks for the patch!
I did change this a bit further so we get the value with field_view_value().

        if ($items = field_get_items('node', $node, 'body')) {
          $terms = field_view_value('node', $node, 'body', $items[0]);
          $form['#attached']['css'] = array(
            drupal_get_path('module', 'terms_of_use') . '/terms_of_use.css'
          );
          $form['terms_of_use']['terms_of_use_text'] = $terms;
        }

Status: Fixed » Closed (fixed)

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