<p>Adding the <code>siteId</code> input field to the form as follows should work:</p>
<pre><code>{{ hiddenInput('siteId', currentSite.id) }}
</code></pre>
<p>Otherwise, please provide an error message so we can help you figure this out.</p>

CC BY-SA 4.0
2023-01-03T18:59:02.593Z
2023-01-03T18:59:02.593Z
Ben Croker
<p>I have created a basic entry form that simply saves a title but I can't seem to get it working.</p>
<p>I copied the code from Craft's documentation but that didn't work so I tried copying the code from another craft 4 site I built recently. The only difference I can see between the site that works and the one that doesn't is that one is a single site and the other is a multi site.</p>
<p>When I copied the code I made sure to change the sectionId. I've specified the siteId in a html tag because it threw an error when I tried:</p>
<pre><code> {{ hiddenInput('siteId', '{{ currentSite.id }}') }}
</code></pre>
<p>Here's my code:</p>
<pre><code>{% extends &quot;_layout.twig&quot; %}

{% block content %}


{# Require that a user is logged in to view this form. #}
{% requireLogin %}


{% macro errorList(errors) %}
  {% if errors %}
  {{ ul(errors, {class: 'errors'}) }}
 {% endif %}
{% endmacro %}

{# If there were any validation errors, an `entry` variable will be 
 passed to the template, which contains the posted values 
 and validation errors. If that’s not set, we’ll default 
 to a new entry. #}
 {% set entry = entry ?? create('craft\\elements\\Entry') %}

 {# Add `enctype=&quot;multipart/form-data&quot;` to `&lt;form&gt;` if you’re 
  uploading files. #}
  &lt;form method=&quot;post&quot; accept-charset=&quot;UTF-8&quot; enctype=&quot;multipart/form-data&quot;&gt;
  {{ csrfInput() }}
  {{ actionInput('entries/save-entry') }}
  {{ redirectInput('artists/{slug}') }}
  {{ hiddenInput('sectionId', '22') }}
  {{ hiddenInput('enabled', '1') }}

   &lt;input type=&quot;hidden&quot; name=&quot;siteId&quot; value=&quot;{{ currentSite.id }}&quot;&gt;


   &lt;label for=&quot;title&quot;&gt;Title&lt;/label&gt;
   {{ input('text', 'title', entry.title, {
     id: 'title',
    }) }}
    {{ _self.errorList(entry.getErrors('title')) }}



    &lt;div class=&quot;mb-6&quot;&gt;
    &lt;button type=&quot;submit&quot; class=&quot;text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 
     focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w- 
     auto px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 
     dark:focus:ring-blue-800&quot;&gt;Publish&lt;/button&gt;
    &lt;/div&gt;
    &lt;/form&gt;


    {% endblock %}
</code></pre>
<p>Any ideas?</p>

CC BY-SA 4.0
2023-01-02T22:12:20.423Z
Have you double-checked that the current user has the necessary permissions to publish entries in the relevant section _and_ site(s)?
Mats Mikkel Rummelhoff
CC BY-SA 4.0
2023-01-02T22:16:07.597Z
If permissions aren't the issue, please elaborate on exactly _how_ the form doesn't work, i.e. does submitting it yield any error messages, or does it simply refresh the page? Or does something else happen? A thing to try is adding a `{{ dump(entry.getErrors()|default }}` to the top of the page (to rule out any additional validation errors beyond the `title`).
Mats Mikkel Rummelhoff
<multi-site><frontend><frontend-form><craft4><entry-form>
Front end entry form not saving on Craft CMS 4 multisite
# Front end entry form not saving on Craft CMS 4 multisite

(Asked by: username_0 on 2023-01-02)

I have created a basic entry form that simply saves a title but I can't seem to get it working.
I copied the code from Craft's documentation but that didn't work so I tried copying the code from another craft 4 site I built recently. The only difference I can see between the site that works and the one that doesn't is that one is a single site and the other is a multi site.
When I copied the code I made sure to change the sectionId. I've specified the siteId in a html tag because it threw an error when I tried:
 {{ hiddenInput('siteId', '{{ currentSite.id }}') }}

Here's my code:
{% extends "_layout.twig" %}

{% block content %}


{# Require that a user is logged in to view this form. #}
{% requireLogin %}


{% macro errorList(errors) %}
  {% if errors %}
  {{ ul(errors, {class: 'errors'}) }}
 {% endif %}
{% endmacro %}

{# If there were any validation errors, an `entry` variable will be 
 passed to the template, which contains the posted values 
 and validation errors. If that’s not set, we’ll default 
 to a new entry. #}
 {% set entry = entry ?? create('craft\\elements\\Entry') %}

 {# Add `enctype="multipart/form-data"` to `` if you’re 
  uploading files. #}
  
  {{ csrfInput() }}
  {{ actionInput('entries/save-entry') }}
  {{ redirectInput('artists/{slug}') }}
  {{ hiddenInput('sectionId', '22') }}
  {{ hiddenInput('enabled', '1') }}

   


   Title
   {{ input('text', 'title', entry.title, {
     id: 'title',
    }) }}
    {{ _self.errorList(entry.getErrors('title')) }}



    
    Publish
    
    


    {% endblock %}

Any ideas?

**Tags:** multi-site, frontend, frontend-form, craft4, entry-form
> **Comments:**
> **username_1**: Have you double-checked that the current user has the necessary permissions to publish entries in the relevant section _and_ site(s)?  
> **username_1**: If permissions aren't the issue, please elaborate on exactly _how_ the form doesn't work, i.e. does submitting it yield any error messages, or does it simply refresh the page? Or does something else happen? A thing to try is adding a `{{ dump(entry.getErrors()|default }}` to the top of the page (to rule out any additional validation errors beyond the `title`).  

---

## 1 answers

### Answer by username_2 on 2023-01-03. Score: 1

Adding the siteId input field to the form as follows should work:
{{ hiddenInput('siteId', currentSite.id) }}

Otherwise, please provide an error message so we can help you figure this out.


---

