Add classes to programmatically added fields
Do something like this to wrap this field in a DIV class --

...
    'background_color' =&gt; array(
        'field_name' =&gt; $fields['field_background_color']['field_name'],
        'label' =&gt; 'The stroke color',
        'bundle' =&gt; 'nji_map',
        'entity_type' =&gt; 'node',
        'attributes' =&gt;array('class'=&gt;array('minicolors')),
        'widget'      =&gt; array(
            'type'    =&gt; 'text_textfield',
        ),
        'settings' =&gt; array(
          'prefix' =&gt; '&lt;div class = "my_field_div_class"&gt;',
          'suffix' =&gt; '&lt;/div&gt;',
        ),
        'display' =&gt; array(
            'default' =&gt; array(
            'label' =&gt; 'above',
            'type' =&gt; 'text_textfield',
            ),
        ),
        'description' =&gt; 'The background color is the color between.',

    )....


You would notice I have added settings along with other properties of the instance, where we can add prefix, sufix, min, max etc. I hope it works..