1

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

1 Answer 1

2

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
  • 1
    Thanks, it works.
    – Priya Goud
    Commented Aug 26, 2021 at 6:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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