adding a  smart function for custom form render to custom class to custom field container:
$form->fieldname('fieldname')->has_error('class="error"');