[SalesForce] VF component dynamic inputField

I have the following component,

<apex:component >
<apex:attribute name="label" description="This is pretty name for this input" type="String" required="true"/>
<apex:attribute name="input" description="A one word description of this label" type="sObject" required="true"/>
<div class="form-group col-md-6">
  <label for="input" class="col-md-2 control-label">{!label}</label>
  <div class="col-md-6 form-control-wrapper">
    <apex:inputField styleClass="form-control" id="input" value="{!input}" />
    <span class="material-input"></span>
  </div>
</div>
</apex:component>

The problem is that I can not save this component. I get this error,

Error: Could not resolve the entity from value
binding '{!input}'. can only be used with SObjects,
or objects that are Visualforce field component resolvable.

I want this to be dynamic so that I can pass whatever value I want for the inputField and it will write the same markup every time. Does anyone know how to do this?

Best Answer

The value in the <apex:inputField> should always be associated with a field of a sobject. You could do something like this:

<apex:component>
    <apex:attribute name="inputObject" type="sObject" description="Object Name"/>
    <apex:attribute name="inputFieldName" type="String" description="Field Name"/>
    <apex:inputField value="{!inputObject[inputFieldName]}"/>
</apex:component>