How to get handle of Field in getInputHtml() function. This is my function:

 public function getInputHtml($value, ElementInterface $element = null): string
        $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;

You can use $this->handle to access the field handle. Make sure you're using the trait craft\base\FieldTrait which includes the handle property.

  • 1
    Thanks, it works.
    – Priya Goud
    Aug 26 at 6:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.