Answers.Body: <p>You'll need to use the Fields service (this changed in Craft 3):</p>
  <pre><code>{% set body = craft.app.fields.getFieldByHandle('body') %}
  </code></pre>
  <p>For more info see <a href="https://craftcms.com/docs/4.x/dev/global-variables.html#common-services" rel="nofollow noreferrer">Common Services</a> in the docs.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-18T18:14:52.197Z
Answers.Text: Thank you! I realised this at the exact same time you posted your answer of course! I'll accept your answer with thanks however.
Answers.UserDisplayName: Tchick
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-18T18:12:27.263Z
Answers.LastActivityDate: 2022-11-18T18:12:27.263Z
Answers.UserDisplayName: CraftQuest
Answers.Body: <p>I see craft.fields.getFieldByHandle() is deprecated and replaced with craft.app.fields.getFieldByHandle()</p>
  <p>See: <a href="https://craftcms.stackexchange.com/a/35811/4060">https://craftcms.stackexchange.com/a/35811/4060</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-18T18:12:54.800Z
Answers.LastActivityDate: 2022-11-18T18:12:54.800Z
Answers.UserDisplayName: Tchick
Body: <p>In Craft 2, I used to be able to do this:
  <a href="https://craftcms.com/docs/2.x/templating/craft.fields.html#getfieldbyhandle-handle" rel="nofollow noreferrer">https://craftcms.com/docs/2.x/templating/craft.fields.html#getfieldbyhandle-handle</a></p>
  <pre><code>{% set body = craft.fields.getFieldByHandle('body') %}
  {{ body.instructions }}
  </code></pre>
  <p>In Craft 4 this no longer works - is there an updated syntax?
  I need to be able to get the field name when I only have its handle.</p>
  
Tags: <templating><craft4>
Title: Craft 4: How do I get field by handle?
ThreadText: # Craft 4: How do I get field by handle?
  
  (Asked by: username_0 on 2022-11-18)
  
  In Craft 2, I used to be able to do this:
  <https://craftcms.com/docs/2.x/templating/craft.fields.html#getfieldbyhandle-handle>
  
  ```
  {% set body = craft.fields.getFieldByHandle('body') %}
  {{ body.instructions }}
  
  ```
  
  In Craft 4 this no longer works - is there an updated syntax?
  I need to be able to get the field name when I only have its handle.
  
  **Tags:** templating, craft4
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2022-11-18. Score: 2 | Accepted answer
  
  You'll need to use the Fields service (this changed in Craft 3):
  
  ```
  {% set body = craft.app.fields.getFieldByHandle('body') %}
  
  ```
  
  For more info see [Common Services](https://craftcms.com/docs/4.x/dev/global-variables.html#common-services) in the docs.
  
  > **Comments:**
  > **username_0**: Thank you! I realised this at the exact same time you posted your answer of course! I'll accept your answer with thanks however.  
  
  ---
  
  ### Answer by username_0 on 2022-11-18. Score: 1
  
  I see craft.fields.getFieldByHandle() is deprecated and replaced with craft.app.fields.getFieldByHandle()
  
  See: <https://craftcms.stackexchange.com/a/35811/4060>
  
  
  ---
  
  