Answers.Body: <p>There might be other ways, but here's one possibility:</p>
  <pre><code>{{ craft.app.fields.getFieldByHandle('yourFieldHandle').className() }}
  </code></pre>
  <p>This will return a string of <code>craft\fields\PlainText</code>, <code>craft\fields\Lightswitch</code> etc, which you can then use in conditionals/switch statements.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-22T19:12:57.157Z
Answers.Text: Thank you, that worked! But why is it suddenly that complicated?
Answers.UserDisplayName: Marcus Scheller
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-23T10:20:28.223Z
Answers.Text: A question I ask myself almost daily... not so much in relation to Craft, but the whole web dev industry. I'm not best placed to answer it in relation to Craft, but I would hazard a guess that these kind of changes relate to the fact that Craft 3 is far more sophisticated than Craft 2: the added sophistication means technical debt needs to be very tightly managed, and limiting a field's output to be a simple string instead of a complex object with actionable methods like `getField()` is probably a significant performance boost. Just guessing, who knows...
Answers.UserDisplayName: James Smith
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-05-02T20:24:25.290Z
Answers.Text: Thanks James. I was jumping through all sort of hoops with field.hasProperty() before finding this. Much simpler than what I was doing :)
Answers.UserDisplayName: Jonathan Schofield
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-22T14:02:22.510Z
Answers.LastActivityDate: 2020-06-22T14:02:22.510Z
Answers.UserDisplayName: James Smith
Body: <p>I need to get the field type in my templates like I used to do: <code>field.getField.type</code> but that does not seem to be working in Craft 3 anymore. The result is always <code>null</code>. It also seems that the »type« column is gone completely from the craft_fields table.</p>
  <p>How do I get the field type in Craft 3?</p>
  
Tags: <templating><craft3><field>
Title: Get field type in templates
ThreadText: # Get field type in templates
  
  (Asked by: username_0 on 2020-06-22)
  
  I need to get the field type in my templates like I used to do: `field.getField.type` but that does not seem to be working in Craft 3 anymore. The result is always `null`. It also seems that the »type« column is gone completely from the craft\_fields table.
  
  How do I get the field type in Craft 3?
  
  **Tags:** templating, craft3, field
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-06-22. Score: 4 | Accepted answer
  
  There might be other ways, but here's one possibility:
  
  ```
  {{ craft.app.fields.getFieldByHandle('yourFieldHandle').className() }}
  
  ```
  
  This will return a string of `craft\fields\PlainText`, `craft\fields\Lightswitch` etc, which you can then use in conditionals/switch statements.
  
  > **Comments:**
  > **username_0**: Thank you, that worked! But why is it suddenly that complicated?  
  > **username_1**: A question I ask myself almost daily... not so much in relation to Craft, but the whole web dev industry. I'm not best placed to answer it in relation to Craft, but I would hazard a guess that these kind of changes relate to the fact that Craft 3 is far more sophisticated than Craft 2: the added sophistication means technical debt needs to be very tightly managed, and limiting a field's output to be a simple string instead of a complex object with actionable methods like `getField()` is probably a significant performance boost. Just guessing, who knows...  
  > **username_2**: Thanks username_1. I was jumping through all sort of hoops with field.hasProperty() before finding this. Much simpler than what I was doing :)  
  
  ---
  
  