- <% profile_config.andand.each do |entry| %>
- <%
- label = entry['required'] ? '* ' : ''
- label += entry['form_field_title']
- value = current_user_profile[entry['key'].to_sym] if current_user_profile
- %>
- <div class="form-group">
- <label for="<%=entry['key']%>"
- class="col-sm-3 control-label"
- style=<%="color:red" if entry['required']&&!value%>> <%=label%>
- </label>
- <% if entry['type'] == 'select' %>
- <div class="col-sm-9">
- <select class="form-control" id="<%=entry['key']%>" name="<%=entry['key']%>">
- <% entry['options'].each do |option| %>
- <option value="<%=option%>" <%='selected' if option==value%>><%=option%></option>
- <% end %>
- </select>
- </div>
- <% else %>
- <div class="col-sm-9">
- <input type="text" class="form-control" id="<%=entry['key']%>" name="<%=entry['key']%>" placeholder="<%=entry['form_field_description']%>" value="<%=value%>" ></input>
- </div>
- <% end %>
- </div>
+ <% profile_config.kind_of?(Array) && profile_config.andand.each do |entry| %>
+ <% if entry[:Key] %>
+ <%
+ show_save_button = true
+ label = entry[:Required] ? '* ' : ''
+ label += entry[:FormFieldTitle]
+ value = current_user_profile[entry[:Key].to_sym] if current_user_profile
+ %>
+ <div class="form-group">
+ <label for="<%=entry[:Key]%>"
+ class="col-sm-3 control-label"
+ style=<%="color:red" if entry[:Required]&&(!value||value.empty?)%>> <%=label%>
+ </label>
+ <% if entry[:Type] == 'select' %>
+ <div class="col-sm-8">
+ <select class="form-control" name="user[prefs][profile][<%=entry[:Key]%>]">
+ <% entry[:Options].each do |option, _| %>
+ <% option = option.to_s %>
+ <option value="<%=option%>" <%='selected' if option==value%>><%=option%></option>
+ <% end %>
+ </select>
+ </div>
+ <% else %>
+ <div class="col-sm-8">
+ <input type="text" class="form-control" name="user[prefs][profile][<%=entry[:Key]%>]" placeholder="<%=entry[:FormFieldDescription]%>" value="<%=value%>" ></input>
+ </div>
+ <% end %>
+ </div>
+ <% end %>