src/fields/Width.php
public function getInputHtml($value, ElementInterface $element = null): string
    {
        // Register our asset bundle
        Craft::$app->getView()->registerAssetBundle(WidthFieldtypeAsset::class);

        // Get our id and namespace
        $id = Craft::$app->getView()->formatInputId($this->handle);
        $namespacedId = Craft::$app->getView()->namespaceInputId($id);

        Craft::$app->getView()->registerJs("new WidthSelectInput('{$namespacedId}');");

        // Render the input template
        return Craft::$app->getView()->renderTemplate(
            'width-fieldtype/_components/fields/Width_input',
            [
                'name'         => $this->handle,
                'value'        => $value,
                'field'        => $this,
                'id'           => $id,
                'namespacedId' => $namespacedId,
                'allOptions'   => self::getOptions(),
            ]
        );
    }
public function getInputHtml($value, ElementInterface $element = null): string
    {
        // Register our asset bundle
        Craft::$app->getView()->registerAssetBundle(WidthFieldtypeAsset::class);

        // Get our id and namespace
        $id = Craft::$app->getView()->formatInputId($this->handle);
        $namespacedId = Craft::$app->getView()->namespaceInputId($id);

        Craft::$app->getView()->registerJs("new WidthSelectInput('{$namespacedId}');");

        // Render the input template
        return Craft::$app->getView()->renderTemplate(
            'width-fieldtype/_components/fields/Width_input',
            [
                'name'         => $this->handle,
                'value'        => $value,
                'field'        => $this,
                'id'           => $id,
                'namespacedId' => $namespacedId,
                'allOptions'   => self::getOptions(),
            ]
        );
    }
Returns the field’s input HTML.

@param mixed                 $value   The field’s value.
This will either be the [[normalizeValue() normalized value]],
raw POST data (i.e. if there was a validation error), or null
@param ElementInterface|null $element The element the field is associated with, if there is one

@throws \Twig_Error_Loader
@throws \yii\base\Exception
@throws \yii\base\InvalidConfigException

@return string The input HTML.