By default when you add a translation your fields get pre-filled with the content of the original language. Is there a way to stop this behaviour for specific fields, in this case an image field. Both the node and field are set to translatable. The image field still needs to be translatable, but the original content should not get copied into the translation.
Reasoning for this is because on our project we have a master language
which will provide default content if no localised content is found. So if we upload an image in the master language en
and no image is uploaded for nl
we use the image of the en
language.
But by default the image is copied into the translation, so if the image needs to be updated for the master language
, you then need to re-visit every translation and change the image here as well.
Practical example. I created a node in the language English
and uploaded an image for field field_series_image
. Now when I add a translation for Dutch
when I hit the node/{nid}/edit/add/en/nl
page I would like to have an empty image field and not pre-filled with the values from the source language en
.
I have tried setting and unsetting a lot of values but none of them seemed to work. I tried to do this in the form_alter hook like this:
my_module_form_alter(&$form, &$form_state, $form_id) {
if ($form_id === 'my_custom_node_form_id') {
if (strpos($form['#action'], '/edit/add/') > 0) {
// Logic went here.
}
}
}
Things I have tried:
- Unsetting the field in the
$form_state['build_info']['args']
array - Unsetting the default value in the
$form
array - Unsetting the field in the
$form['#entity']
array. - Setting the default value to 0 (
$form['field_series_image']['nl'][0]['#default_value'] = 0
)
None of them seemed to work, maybe because the image field is a widget?
TLDNR;
When adding a translation (so being on node/{nid}/edit/add/en/nl
) I want to empty a image field using some hook. So the field is empty on the page and not saved using the values from the original node.