Answers.Body: <p>You can use <code>$this-&gt;handle</code> to access the field handle. Make sure you're using the trait <a href="https://docs.craftcms.com/api/v3/craft-base-fieldtrait.html" rel="nofollow noreferrer">craft\base\FieldTrait</a> which includes the <a href="https://docs.craftcms.com/api/v3/craft-base-fieldtrait.html#handle" rel="nofollow noreferrer"><code>handle</code> property</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-26T06:50:42.727Z
Answers.Text: Thanks, it works.
Answers.UserDisplayName: Priya Goud
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-25T10:59:55.523Z
Answers.LastActivityDate: 2021-08-25T10:59:55.523Z
Answers.UserDisplayName: MoritzLost
Body: <p>How to get handle of Field in getInputHtml() function.
  This is my function:</p>
  <pre><code> public function getInputHtml($value, ElementInterface $element = null): string
      { 
          $name='test';                  
          
          $id = \craft\helpers\Html::id($name);    
          
          $namespacedId = Craft::$app-&gt;view-&gt;namespaceInputId($id);                
          $data=Craft::$app-&gt;view-&gt;renderTemplate('craft-vimeo-handle/_fieldinput', [
              'name' =&gt; $name,
              'id' =&gt; $id,
              'namespacedId' =&gt; $namespacedId,
              'value' =&gt; $value,
          ]);           
          return $data;
      }
  </code></pre>
  
Tags: <craft3>
Title: Craft Plugin Implementation: How to get handle of Field in getInputHtml() function
ThreadText: # Craft Plugin Implementation: How to get handle of Field in getInputHtml() function
  
  (Asked by: username_0 on 2021-08-25)
  
  How to get handle of Field in getInputHtml() function.
  This is my function:
  
  ```
   public function getInputHtml($value, ElementInterface $element = null): string
      { 
          $name='test';                  
          
          $id = \craft\helpers\Html::id($name);    
          
          $namespacedId = Craft::$app->view->namespaceInputId($id);                
          $data=Craft::$app->view->renderTemplate('craft-vimeo-handle/_fieldinput', [
              'name' => $name,
              'id' => $id,
              'namespacedId' => $namespacedId,
              'value' => $value,
          ]);           
          return $data;
      }
  
  ```
  
  **Tags:** craft3
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-08-25. Score: 2 | Accepted answer
  
  You can use `$this->handle` to access the field handle. Make sure you're using the trait [craft\base\FieldTrait](https://docs.craftcms.com/api/v3/craft-base-fieldtrait.html) which includes the [`handle` property](https://docs.craftcms.com/api/v3/craft-base-fieldtrait.html#handle).
  
  > **Comments:**
  > **username_0**: Thanks, it works.  
  
  ---
  
  