Our forms need to support the View/Edit mode. In the Edit mode all the fields are editable. In the View mode, they are read-only. Maybe there is a CSS style that can be applied, or maybe the Input Boxes can be converted to Labels.
FYI, our app is in Spring MVC, some ideas we've examined:
- Extend Spring MVC's Form tags to support View/Edit from the server-side
- Some JS/jQuery tweaks
- Some CSS tweaks
I found a similar thread on this: Implement read / edit mode in form
<form data-mode="read">
<input value="Hello" />
</form>
if($('form').data('mode') == 'read'){ //remove fields and add text
$('form').find(':input').each(function(){
$(this).replaceWith($('<span>' + $(this).val() + '</span>');
});
}
The suggestion was to have a Form tag attribute, e.g. "data-mode", but is this a custom attribute?
What are some standard, good solutions to this problem, whether it's from the JS, CSS, or SpringMVC (server-side) point of view?