Add to structure field - default language

I’m adding content to a structure field though a frontend form. That works great. Thanks to the cookbook recipe. But now I’m trying to add the content only to the default language. So I just want to have one single txt file for every submit. The users set language should matter.

I tried something like:

addToStructureDownload($page->find('mypage')->content('en'), 'emailsubscription', $data);

also

$page->find('mypage')->uri('en')

but with no luck.

What would be the easiest way to submit data only to the default language?

Thanks in for any kind of help.

You have to pass the language to the update function: https://getkirby.com/docs/cheatsheet/page/update

Of course… it’s in the update function. I knew that I’ve used it in another project before…

Thanks for your fast support.

i guess @texnixe helped me on that on another thread sometime ago, (or any other kirby user) and just as a tipp, instead of “hardcoding” english => ‘en’ (or any other default language) you can get it automatically as well…

        $page->update([
	    'field' => $value,
	  ], $site->defaultLanguage()->code());
	}

Thanks for this neat hint. That helps for making it more future proof.