An extremely simple implementation would be to directly return some HTML:

return'<textarea name="'.$name.'">'.$value.'</textarea>';

For more complex inputs, you might prefer to create a template, and render it via
{@link TemplatesService::render()}. For example, the following code would render a template loacated at
craft/plugins/myplugin/templates/_fieldinput.html, passing the $name and $value variables to it:

If you need to tie any JavaScript code to your input, it’s important to know that any name= and id=
attributes within the returned HTML will probably get {@link TemplatesService::namespaceInputs() namespaced},
however your JavaScript code will be left untouched.

As you can see, that JavaScript code will not be able to find the textarea, because the textarea’s id=
attribute was changed from foo to namespace-foo.

Before you start adding namespace- to the beginning of your element ID selectors, keep in mind that the actual
namespace is going to change depending on the context. Often they are randomly generated. So it’s not quite
that simple.

Thankfully, {@link TemplatesService} provides a couple handy methods that can help you deal with this:

{@link TemplatesService::namespaceInputId()} will give you the namespaced version of a given ID.

{@link TemplatesService::namespaceInputName()} will give you the namespaced version of a given input name.

{@link TemplatesService::formatInputId()} will format an input name to look more like an ID attribute value.

So here’s what a getInputHtml() method that includes field-targeting JavaScript code might look like:

publicfunctiongetInputHtml($name,$value){// Come up with an ID value based on $name$id=craft()->templates->formatInputId($name);// Figure out what that ID is going to be namespaced into$namespacedId=craft()->templates->namespaceInputId($id);// Render and return the input templatereturncraft()->templates->render('myplugin/_fieldinput',array('name'=>$name,'id'=>$id,'namespacedId'=>$namespacedId,'value'=>$value));}