Answers.Body: <p>Craft has no default process to handle such things, you need to do that on your own. Here is a form and a controller example how it could be achieved.</p>
  
  <pre class="lang-twig prettyprint-override"><code>{# just to show you.. you can edit existing one as well #}
  {% set entry1 = craft.entries.id(11).siteId(1).one() %}
  {% set entry2 = craft.entries.id(11).siteId(2).one() %}
  
  &lt;form method="post"&gt;
      {{ csrfInput() }}
      &lt;input type="hidden" name="action" value="my-module/save"&gt;
  
      {# if you have an ID use it #}
      {% if entry1 is defined and entry1 is not null %}
          &lt;input type="hidden" name="id" value="{{ entry1.id }}"&gt;
      {% endif %}
  
      {# the site ids you want to store, you can as well use the handle or whatever you want #}
      &lt;input type="hidden" name="siteId[]" value="1"&gt;
      &lt;input type="hidden" name="siteId[]" value="2"&gt;
  
      {# title #}
      &lt;p&gt;Title Site 1&lt;/p&gt;
      &lt;input type="text" name="title[1]" value="{{ entry1.title?? '' }}"&gt;
  
      &lt;p&gt;Title Site 2&lt;/p&gt;
      &lt;input type="text" name="title[2]" value="{{ entry2.title?? '' }}"&gt;
  
      {# a field #}
      &lt;p&gt;Headline site 1&lt;/p&gt;
      &lt;input type="text" name="fields[1][headline]" value="{{ entry1.headline?? '' }}"&gt;
  
      &lt;p&gt;Headline site 2&lt;/p&gt;
      &lt;input type="text" name="fields[2][headline]" value="{{ entry2.headline?? '' }}"&gt;
  
      {# slug #}
      &lt;p&gt;Slug site 1&lt;/p&gt;
      &lt;input type="text" name="slug[1]" value="{{ entry1.slug?? '' }}"&gt;
  
      &lt;p&gt;Slug site 2&lt;/p&gt;
      &lt;input type="text" name="slug[2]" value="{{ entry2.slug?? '' }}"&gt;
  
      &lt;input type="submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And then in your Controller</p>
  
  <pre class="lang-php prettyprint-override"><code>/**
   * actionIndex
   *
   *
   * @throws \Throwable
   * @throws \craft\errors\ElementNotFoundException
   * @throws \yii\base\Exception
   * @throws \yii\web\BadRequestHttpException
   * @return \yii\web\Response
   */
  public function actionIndex(): \yii\web\Response
  {
      // grab all the sites you want to store
      $request = Craft::$app-&gt;getRequest();
      $sites = $request-&gt;getRequiredBodyParam('siteId');
  
      $elements = Craft::$app-&gt;getElements();
      // change the handle of course
      $section = Craft::$app-&gt;getSections()-&gt;getSectionByHandle('news');
      // only applies to me, you need to figure out the type on your own
      // note: don't just grab things by id if you use the project config
      // please check if those variables are not null
      $type = $section-&gt;getEntryTypes()[0];
  
      $elementId = null;
      $element = null;
      foreach ($sites as $siteId) {
          // TODO check if the site exists
          $elementId = (int)$request-&gt;getBodyParam('id', $elementId);
          if ($elementId !== 0) {
              $element = $elements-&gt;getElementById($elementId, Entry::class, (int) $siteId);
          }
  
          if ($element === null) {
              $element = new Entry(
                  [
                      'sectionId' =&gt; $section-&gt;id,
                      'typeId'    =&gt; $type-&gt;id
                  ]
              );
          }
  
          $this-&gt;populateModel($element, $siteId);
          if($elements-&gt;saveElement($element) === false){
              // handle errors somehow
              echo "&lt;pre&gt;";
              var_dump($element-&gt;getErrors());
              echo "&lt;/pre&gt;";
              die();
          }
  
          $elementId = $element-&gt;id;
      }
  
      return $this-&gt;asJson(['success' =&gt; true]);
  }
  
  /**
   * populateModel
   *
   * @param \craft\base\ElementInterface $element
   * @param                              $siteId
   */
  public function populateModel(ElementInterface $element, $siteId)
  {
      /** @var Entry $element */
      $request = Craft::$app-&gt;getRequest();
      $element-&gt;title = $request-&gt;getBodyParam('title.' . $siteId, $element-&gt;title);
      $element-&gt;slug = $request-&gt;getBodyParam('slug.' . $siteId, $element-&gt;slug);
      $element-&gt;enabled = $request-&gt;getBodyParam('enabled.' . $siteId, $element-&gt;enabled);
      // and so on.. continue with the rest you want to post + the author..
  
      $fieldsLocation = 'fields.' . $siteId;
      $element-&gt;setFieldValuesFromRequest($fieldsLocation);
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-09T09:45:57.870Z
Answers.Text: while that does work for submitting a value for each site seperately, the goal is to be able to both languages in 1 submit. I'll edit the question to better reflect that.
Answers.UserDisplayName: mrsmn
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-09T09:39:13.670Z
Answers.LastActivityDate: 2019-04-10T07:12:27.030Z
Answers.LastEditDate: 2019-04-10T07:12:27.030Z
Answers.UserDisplayName: Robin Schambach
Body: <p>I've got 2 sites, each with a locale (dutch - nl &amp; french - fr). I've set up a frontend entry form that works nicely for all not translated fields, I am however struggling to get it to accept submissions for the translated field in both languages at once.</p>
  
  <p>So what should the name of my HTML input tag be so I can use a translated field in a front-end entry form ?</p>
  
  <hr>
  
  <p>EDIT: </p>
  
  <p>As this might not have been clear before, the goal is to be able to send content for both languages in a single form submit. As I understand this will involve some PHP code, which is certainly no problem, but I'm a bit stuck as to what to add where so any pointers are much appreciated.</p>
  
  <hr>
  
  <p>EXAMPLE</p>
  
  <p>I've got a field with the handle <code>description</code></p>
  
  <p>I've tried the following input names but without result
   - <code>fields[description][nl]</code>
   - <code>fields[nl][description]</code></p>
  
Tags: <craft3><localization><entry><form>
Title: Entry form with field translated accross multiple sites
ThreadText: # Entry form with field translated accross multiple sites
  
  (Asked by: username_0 on 2019-04-09)
  
  I've got 2 sites, each with a locale (dutch - nl & french - fr). I've set up a frontend entry form that works nicely for all not translated fields, I am however struggling to get it to accept submissions for the translated field in both languages at once.
  
  So what should the name of my HTML input tag be so I can use a translated field in a front-end entry form ?
  
  ---
  
  EDIT:
  
  As this might not have been clear before, the goal is to be able to send content for both languages in a single form submit. As I understand this will involve some PHP code, which is certainly no problem, but I'm a bit stuck as to what to add where so any pointers are much appreciated.
  
  ---
  
  EXAMPLE
  
  I've got a field with the handle `description`
  
  I've tried the following input names but without result
  - `fields[description][nl]`
  - `fields[nl][description]`
  
  **Tags:** craft3, localization, entry, form
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-04-09. Score: 1 | Accepted answer
  
  Craft has no default process to handle such things, you need to do that on your own. Here is a form and a controller example how it could be achieved.
  
  ```twig
  {# just to show you.. you can edit existing one as well #}
  {% set entry1 = craft.entries.id(11).siteId(1).one() %}
  {% set entry2 = craft.entries.id(11).siteId(2).one() %}
  
  <form method="post">
      {{ csrfInput() }}
      <input type="hidden" name="action" value="my-module/save">
  
      {# if you have an ID use it #}
      {% if entry1 is defined and entry1 is not null %}
          <input type="hidden" name="id" value="{{ entry1.id }}">
      {% endif %}
  
      {# the site ids you want to store, you can as well use the handle or whatever you want #}
      <input type="hidden" name="siteId[]" value="1">
      <input type="hidden" name="siteId[]" value="2">
  
      {# title #}
      <p>Title Site 1</p>
      <input type="text" name="title[1]" value="{{ entry1.title?? '' }}">
  
      <p>Title Site 2</p>
      <input type="text" name="title[2]" value="{{ entry2.title?? '' }}">
  
      {# a field #}
      <p>Headline site 1</p>
      <input type="text" name="fields[1][headline]" value="{{ entry1.headline?? '' }}">
  
      <p>Headline site 2</p>
      <input type="text" name="fields[2][headline]" value="{{ entry2.headline?? '' }}">
  
      {# slug #}
      <p>Slug site 1</p>
      <input type="text" name="slug[1]" value="{{ entry1.slug?? '' }}">
  
      <p>Slug site 2</p>
      <input type="text" name="slug[2]" value="{{ entry2.slug?? '' }}">
  
      <input type="submit">
  </form>
  
  ```
  
  And then in your Controller
  
  ```php
  /**
   * actionIndex
   *
   *
   * @throws \Throwable
   * @throws \craft\errors\ElementNotFoundException
   * @throws \yii\base\Exception
   * @throws \yii\web\BadRequestHttpException
   * @return \yii\web\Response
   */
  public function actionIndex(): \yii\web\Response
  {
      // grab all the sites you want to store
      $request = Craft::$app->getRequest();
      $sites = $request->getRequiredBodyParam('siteId');
  
      $elements = Craft::$app->getElements();
      // change the handle of course
      $section = Craft::$app->getSections()->getSectionByHandle('news');
      // only applies to me, you need to figure out the type on your own
      // note: don't just grab things by id if you use the project config
      // please check if those variables are not null
      $type = $section->getEntryTypes()[0];
  
      $elementId = null;
      $element = null;
      foreach ($sites as $siteId) {
          // TODO check if the site exists
          $elementId = (int)$request->getBodyParam('id', $elementId);
          if ($elementId !== 0) {
              $element = $elements->getElementById($elementId, Entry::class, (int) $siteId);
          }
  
          if ($element === null) {
              $element = new Entry(
                  [
                      'sectionId' => $section->id,
                      'typeId'    => $type->id
                  ]
              );
          }
  
          $this->populateModel($element, $siteId);
          if($elements->saveElement($element) === false){
              // handle errors somehow
              echo "<pre>";
              var_dump($element->getErrors());
              echo "</pre>";
              die();
          }
  
          $elementId = $element->id;
      }
  
      return $this->asJson(['success' => true]);
  }
  
  /**
   * populateModel
   *
   * @param \craft\base\ElementInterface $element
   * @param                              $siteId
   */
  public function populateModel(ElementInterface $element, $siteId)
  {
      /** @var Entry $element */
      $request = Craft::$app->getRequest();
      $element->title = $request->getBodyParam('title.' . $siteId, $element->title);
      $element->slug = $request->getBodyParam('slug.' . $siteId, $element->slug);
      $element->enabled = $request->getBodyParam('enabled.' . $siteId, $element->enabled);
      // and so on.. continue with the rest you want to post + the author..
  
      $fieldsLocation = 'fields.' . $siteId;
      $element->setFieldValuesFromRequest($fieldsLocation);
  }
  
  ```
  
  > **Comments:**
  > **username_0**: while that does work for submitting a value for each site seperately, the goal is to be able to both languages in 1 submit. I'll edit the question to better reflect that.  
  
  ---
  
  