0

I have a taxonomy term with an image field in it.

The problem is when I try to translate the taxonomy term and choose an image, the term is not translated and the language is set back to Language Neutral on save action.

Here is the message who came up when I hit the save button

Created new term testtttttt.
You are not authorized to access this page.

It's only happened when I fill the Image field, otherwise the taxonomy is translated correctly.

It's seem to be a new bug in drupal https://www.drupal.org/node/2227181

Thanks

2 Answers 2

0

As a temporary solution, when you add the image don't upload it, just select it and save the term, it will translate correctly.

I will update the answer once I find why it is not working when the image is uploaded first.

Update : The problem is that when you upload the image the $form gets cached without the translation details. Use the following code as workaround.

function MYMODULE_form_alter(&$form, &$form_state, $form_id){
   if(($form_id=='taxonomy_form_term') && (!isset($form_state['triggering_element']) || $form_state['triggering_element']['#id']!='edit-delete')){
       $form['#after_build'][] = 'MYMODULE_after_build';
}

function MYMODULE_after_build($form, &$form_state) {
     if(!isset($form_state['storage']['rebuilding'])){
        $form_state['storage']['rebuilding']=TRUE;

     }
     else{
        $form_state['no_cache']=TRUE; 
     }

}
2
  • Thanks a lot wolverine, I'll continue to find the reason why too. Jul 1, 2014 at 18:13
  • @Jean-Francois Updated the answer
    – msmani
    Jul 2, 2014 at 10:54
1

I tried wolverine's answer but it didn't worked for me, it caused error "#build_id not defined" so I changed it a little, I don't know if it's right solution but it worked for me.

Add only this code in your module:

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
    if (($form_id == 'taxonomy_form_term') && (!isset($form_state['triggering_element']) || $form_state['triggering_element']['#id'] != 'edit-delete')) {
        if (!isset($form_state['storage']['rebuilding'])) {
            $form_state['storage']['rebuilding'] = TRUE;

        } else {
            $form_state['no_cache'] = TRUE;
        }
    }
}

Hope it's helpful for someone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.