powmedia / backbone-forms

Form framework for BackboneJS with nested forms, editable lists and validation
MIT License
2.17k stars 415 forks source link

All editors have readonly mode #452

Closed alemangui closed 8 years ago

alemangui commented 9 years ago

Hi guys,

I've taken a shot at the readonly mode on editors (Briefly discussed in issues 90, 91 and 145) and here's a pull request proposal.

readonly in schema

Each editor can get a { readonly: true } as part of the schema (false by default). Object doesn't have readonliness since it's the subschema which would specify the readonliness for each editor.

\ readonlyTemplate for each editor**

Each editor has a readonlyTemplate, which is rendered if the schema.readonly property is set. This way it is easy to extend an editor to make it appear however we want only by overriding the readonlyTemplate.

_There's one exception: Checkboxes editor. Since the containing el is an unordered list <ul>, we can't achieve readonliness for checkboxes at the el level. The Checkboxes editor implements readonliness inside the _arrayToHtml function._

\ setElAttributes function for tweaking the el**

Instead of having code altering the el attributes in the initialize function, I've created a setElAttributes function which can also be called after the readonly template is rendered.


That's it, let me know what you think and if the PR is accepted I'll update the Readme.md as well as the fiddles linked in it.

alemangui commented 9 years ago

Hey, just chiming in to see if you had any remarks. I'd be happy to discuss and/or consider another approach.

exussum12 commented 8 years ago

Can you remove all of the code in distribution please just leave the src code

alemangui commented 8 years ago

I had deleted the fork on which I based this PR a while ago. I made a new fork/PR in #501

Cheers

exussum12 commented 8 years ago

Closed due to #501