<p>They only have to be unique within a block. So your initial idea would be best. 
Have a <code>galleryMatrix</code> field with an <code>image</code> block and fields with handles <code>imgName</code> and <code>imgAsset</code>.</p>

<p>I don't think you can use <code>name</code> as a handle, because it is a reserved word. <code>Asset</code> may be possible.</p>

CC BY-SA 4.0
2018-11-12T15:31:46.320Z
2018-11-12T15:31:46.320Z
Tom De Smet
<p>About matrix block fields handles: should they be unique ?</p>

<p>For instance if I have a matrix with handle <code>galleryMatrix</code>,
than should I name my block <code>galleryMatrixImage</code> or just <code>image</code>?
And than my fields in my block: <code>galleryMatrixImageName</code>, <code>galleryMatrixImageAsset</code> or <code>name</code> and <code>asset</code>?</p>

<p>I'm not quite sure about how to manage these handles the proper way?</p>

<p>I would prefer being able to name them with short handles, but i'm not sure if they have to be unique within a block, or unique for a whole website ?</p>

<p>Thanks</p>

<craft3>
Best practices to name Matrix fields handles
# Best practices to name Matrix fields handles

(Asked by: username_0 on 2018-11-12)

About matrix block fields handles: should they be unique ?

For instance if I have a matrix with handle `galleryMatrix`,
than should I name my block `galleryMatrixImage` or just `image`?
And than my fields in my block: `galleryMatrixImageName`, `galleryMatrixImageAsset` or `name` and `asset`?

I'm not quite sure about how to manage these handles the proper way?

I would prefer being able to name them with short handles, but i'm not sure if they have to be unique within a block, or unique for a whole website ?

Thanks

**Tags:** craft3


---

## 1 answers

### Answer by username_1 on 2018-11-12. Score: 1

They only have to be unique within a block. So your initial idea would be best.
Have a `galleryMatrix` field with an `image` block and fields with handles `imgName` and `imgAsset`.

I don't think you can use `name` as a handle, because it is a reserved word. `Asset` may be possible.


---

