<p><a href="https://craftcms.stackexchange.com/a/15333/57">Paul is correct</a>, but probably worth adding if you want the full list of "enums" Craft has available you can look at <a href="https://craftcms.com/classreference#craft.app.enums" rel="nofollow noreferrer"><code>craft.app.enums</code></a> in the class reference.</p>

CC BY-SA 3.0
2016-06-03T20:42:16.927Z
2016-06-03T20:42:16.927Z
2017-04-13T12:51:00.303Z
Brad Bell
<p>I don't know if any enum exists (couldn't find it in source), but you could have a look at the contents of the <code>craft/app/fieldtypes</code> folder (and ignore BaseFieldtypes, DataModels and interfaces) to find the identifiers:</p>

<ul>
<li>UsersFieldType.php</li>
<li>TagsFieldType.php</li>
<li>TableFieldType.php</li>
<li>RichTextFieldType.php</li>
<li>RadioButtonsFieldType.php</li>
<li>PositionSelectFieldType.php</li>
<li>PlainTextFieldType.php</li>
<li>NumberFieldType.php</li>
<li>MultiSelectFieldType.php</li>
<li>MatrixFieldType.php</li>
<li>LightswitchFieldType.php</li>
<li>EntriesFieldType.php</li>
<li>DropdownFieldType.php</li>
<li>DateFieldType.php</li>
<li>ColorFieldType.php</li>
<li>CheckboxesFieldType.php</li>
<li>CategoriesFieldType.php</li>
<li>AssetsFieldType.php</li>
</ul>

<p>String identifiers correspond to the file names (without "FieldType.php", obviously).</p>

CC BY-SA 3.0
2016-06-03T13:47:49.877Z
Ah! Seems obvious, yeah… to me it wasn't. I already knew where the field type implementations are located but I didn't see the relation between file name and string identifier. Yep, pretty shortsighted. ;) Shame on me and thanks to you. :) … But still, I hoped there would have been an enum I could use (because of easiness with auto-complete). Nevertheless, get my upvote. Cheers.
Arvid
CC BY-SA 3.0
2016-06-03T12:12:07.483Z
2016-06-03T12:12:07.483Z
Paul
<p>There are several enum classes containing constants such as the <code>SectionType</code> class which I can use to create sections:</p>

<pre><code>//  …
$section = new SectionModel();
$section-&gt;type = SectionType::Single;
//  …
</code></pre>

<p>But what about creating fields? Currently I create fields like so:</p>

<pre><code>//  …
$field = new FieldModel();
$field-&gt;type = 'PlainText';
//  …
</code></pre>

<p>Is there any enum class containing valid identifiers I could use to create a field? Like in the following way?</p>

<pre><code>//  …
$field = new FieldModel();
$field-&gt;type = FieldType::PlainText;     // Does something like this exist?
//  …
</code></pre>

<p>I can't find such a class or any other listing of existing field types, where do I?</p>

<p>Unfortunately, a list of string identifiers is missing on the guide for <a href="https://craftcms.com/docs/plugins/field-types" rel="nofollow">plugin development and field types</a>. The <a href="https://craftcms.com/docs/fields#field-types" rel="nofollow">list of field types</a> only tells me which field types exist but not what identifiers they have.</p>

<plugin-development><fieldtypes>
Which string identifiers for field types do exist?
# Which string identifiers for field types do exist?

(Asked by: username_0 on 2016-06-03)

There are several enum classes containing constants such as the SectionType class which I can use to create sections:
//  …
$section = new SectionModel();
$section->type = SectionType::Single;
//  …

But what about creating fields? Currently I create fields like so:
//  …
$field = new FieldModel();
$field->type = 'PlainText';
//  …

Is there any enum class containing valid identifiers I could use to create a field? Like in the following way?
//  …
$field = new FieldModel();
$field->type = FieldType::PlainText;     // Does something like this exist?
//  …

I can't find such a class or any other listing of existing field types, where do I?
Unfortunately, a list of string identifiers is missing on the guide for plugin development and field types. The list of field types only tells me which field types exist but not what identifiers they have.

**Tags:** plugin-development, fieldtypes


---

## 2 answers

### Answer by username_2 on 2016-06-03. Score: 5 | Accepted answer

I don't know if any enum exists (couldn't find it in source), but you could have a look at the contents of the `craft/app/fieldtypes` folder (and ignore BaseFieldtypes, DataModels and interfaces) to find the identifiers:

* UsersFieldType.php
* TagsFieldType.php
* TableFieldType.php
* RichTextFieldType.php
* RadioButtonsFieldType.php
* PositionSelectFieldType.php
* PlainTextFieldType.php
* NumberFieldType.php
* MultiSelectFieldType.php
* MatrixFieldType.php
* LightswitchFieldType.php
* EntriesFieldType.php
* DropdownFieldType.php
* DateFieldType.php
* ColorFieldType.php
* CheckboxesFieldType.php
* CategoriesFieldType.php
* AssetsFieldType.php

String identifiers correspond to the file names (without "FieldType.php", obviously).

> **Comments:**
> **username_0**: Ah! Seems obvious, yeah… to me it wasn't. I already knew where the field type implementations are located but I didn't see the relation between file name and string identifier. Yep, pretty shortsighted. ;) Shame on me and thanks to you. :) … But still, I hoped there would have been an enum I could use (because of easiness with auto-complete). Nevertheless, get my upvote. Cheers.  

---

### Answer by username_1 on 2016-06-03. Score: 0

[username_2 is correct](https://craftcms.stackexchange.com/a/15333/57), but probably worth adding if you want the full list of "enums" Craft has available you can look at [`craft.app.enums`](https://craftcms.com/classreference#craft.app.enums) in the class reference.


---

