<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>

CC BY-SA 4.0
2021-08-26T06:50:42.727Z
Thanks, it works.
Priya Goud
CC BY-SA 4.0
2021-08-25T10:59:55.523Z
2021-08-25T10:59:55.523Z
MoritzLost
<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>

<craft3>
Craft Plugin Implementation: How to get handle of Field in getInputHtml() function
# 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.  

---

