<p>The <code>fields</code> array may only contain names that represents handles in your <code>fieldLayout</code> but the <code>parent</code> attribute is a property of your object rather than a field - you can set it via <code>parentId</code>. You may want to inspect your CP form in order to see how you need to define attributes</p>

<pre><code>&lt;section class="membersTitle" &gt;
    &lt;label&gt;Date&lt;/label&gt;
    &lt;select name="parentId"&gt;
        {% for entry in craft.entries.section('order').level(1).find() %}
            &lt;option value="{{ entry.id }}"&gt;{{ entry.title }}&lt;/option&gt;
        {% endfor %}
    &lt;/select&gt;
&lt;/section&gt;
</code></pre>

CC BY-SA 4.0
2018-07-29T15:25:41.047Z
thx Robin, so how I can add entry as a child, is it possible?
Alex Ryhluk
CC BY-SA 4.0
2018-07-29T15:26:28.497Z
With the code above (?)
Robin Schambach
CC BY-SA 4.0
2018-07-29T15:28:00.900Z
if you know another way, tell me pls
Alex Ryhluk
CC BY-SA 4.0
2018-07-29T15:29:43.040Z
There is no easier way.. Specify the `parentId` attribute and you are done. You can as well create a custom query to change all necessary columns by hand but just setting the parentId is the way to go
Robin Schambach
CC BY-SA 4.0
2018-07-29T15:18:26.883Z
2018-07-29T15:18:26.883Z
Robin Schambach
<p>Form code:</p>

<pre><code>&lt;section class="membersTitle" &gt;
    &lt;label&gt;Date&lt;/label&gt;
    &lt;select name="fields[parent][]"&gt;
    {% set entries = craft.entries.section('order').level(1) %}
        {% for entry in entries %}
            &lt;option value="{{ entry.id }}"&gt;{{ entry.title }}&lt;/option&gt;
        {% endfor %}
    &lt;/select&gt;
&lt;/section&gt;
</code></pre>

<p>I want to choose Parent from list, and I want to add the element to parent.</p>

<structure>
I try to add element to structure, and I want to add to this element parent ID
# I try to add element to structure, and I want to add to this element parent ID

(Asked by: username_0 on 2018-07-29)

Form code:

    Date
    
    {% set entries = craft.entries.section('order').level(1) %}
        {% for entry in entries %}
            {{ entry.title }}
        {% endfor %}
    


I want to choose Parent from list, and I want to add the element to parent.

**Tags:** structure


---

## 1 answers

### Answer by username_1 on 2018-07-29. Score: 2

The fields array may only contain names that represents handles in your fieldLayout but the parent attribute is a property of your object rather than a field - you can set it via parentId. You may want to inspect your CP form in order to see how you need to define attributes

    Date
    
        {% for entry in craft.entries.section('order').level(1).find() %}
            {{ entry.title }}
        {% endfor %}

> **Comments:**
> **username_0**: thx Robin, so how I can add entry as a child, is it possible?  
> **username_1**: With the code above (?)  
> **username_0**: if you know another way, tell me pls  
> **username_1**: There is no easier way.. Specify the `parentId` attribute and you are done. You can as well create a custom query to change all necessary columns by hand but just setting the parentId is the way to go  

---

