JSFiddle - React, Tailwind, and code Playground

by Jed Lynch

HTML

<div ng-repeat="field in myForm" class="form-group {field.name}}" ng-class="{'has-error': Form.{{ field.name }}.$dirty && Form.{{ field.name }}.$invalid}">
    <label class="control-label">{{ field.label }}</label>
    <input type="text" class="form-control" name="{{ field.name }}" ng-model="adherent.{{ field.name }}" ng-required="currentStep == 2">
    <span ng-if="{{ field.required }}" class="error text-small block" ng-if="Form.numeroSecuriteSociale.$dirty && Form.numeroSecuriteSociale.$error.required">Field required !</span>
</div>

JavaScript

$scope.myForm= [{
    'type': 'text',
    'name': 'field1',
    'required': true,
    'label': 'My field 1',
    'ng': [{'ng-blur': 'function1'}]
}, {
    'type': 'text',
    'name': 'field2',
    'required': false,
    'label': 'My field 2',
}];