angular-form-builder icon indicating copy to clipboard operation
angular-form-builder copied to clipboard

Updated your select & radio control

Open JoeGrasso opened this issue 10 years ago • 0 comments

I noticed with regard to the radio and select control there were default values and I can think of scenarios where that may not be the case and one may want them as blank, as well as blank but required. If anyone is interested, here is how I altered the controls:

  1. Radio Control:

    <div class="form-group">
       <label for="{{formName+index}}" class="col-sm-2 control-label" ng-class="{'fb-required':required}">{{label}}</label>
    <div class="col-sm-10">
        <div class='radio' ng-repeat="item in options track by $index">
            <label>
                <input data-ng-if="required == false" name='{{formName+index}}' ng-model="$parent.inputText" validator-group="{{formName}}" ng-value='false' type='radio'/>
                <input data-ng-if="required == true" required name='{{formName+index}}' ng-model="$parent.inputText" validator-group="{{formName}}" ng-value='false' type='radio'/>
            {{item}}
            </label>
        </div>
        <p class='help-block'>{{description}}</p>
    </div>
    

  1. Select Control:

    <div class="form-group">
     <label for="{{formName+index}}" class="col-sm-2 control-label" ng-class="{'fb-required':required}">{{label}}</label>
     <div class="col-sm-6">
         <input type='hidden' ng-model="inputText" validator-required="{{required}}" validator-group="{{formName}}"/>
       <select ng-hide="multiple" data-ng-if="required == false"
               ng-options="value for value in options"
               id="{{formName+index}}" class="form-control"
               ng-model="inputText"
               ng-init="inputText=0">
       <option value="" selected="selected">Please Select</option>
           </select>
       <select required ng-hide="multiple" data-ng-if="required == true"
               ng-options="value for value in options"
            id="{{formName+index}}" class="form-control"
            ng-model="inputText"
            ng-init="inputText=0">
        <option value="" selected="selected">Please Select</option>
       </select>
       <select ng-show="multiple" data-ng-if="required == false"
            ng-options="value for value in options"
            id="{{formName+index}}"
            class="form-control"
            ng-model="inputText"
            multiple ng-init="inputText=0">
           <option value="" selected="selected">Please Select</option>
       </select>
    
       <select required ng-show="multiple" data-ng-if="required == true"
            ng-options="value for value in options"
            id="{{formName+index}}"
            class="form-control"
            ng-model="inputText"
            multiple ng-init="inputText=0">
           <option value="" selected="selected">Please Select</option>
       </select>
       <p class='help-block'>{{description}}</p>
      </div>
    

JoeGrasso avatar Feb 18 '15 14:02 JoeGrasso