Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add read only mode for editors #145

Open
powmedia opened this issue Oct 12, 2012 · 2 comments
Open

Add read only mode for editors #145

powmedia opened this issue Oct 12, 2012 · 2 comments

Comments

@powmedia
Copy link
Owner

Should work across editors.

Example use case: Making it easy to create the 'show' view for a model in a CRUD app.

@alemangui
Copy link
Contributor

Hello,

What about having a readonly property in the schema? This could be read inside each editor and each editor would handle it differently.

schema: { 
  name: { readonly: true } 
}

For instance, maybe the text editor will just add the readonly attribute via jQuery in the initialize function, whereas editors that have templates (e.g., radio) can add another template readonlyTemplate which would be chosen in case the readonly property is there.

Form.editors.Radio = Form.editors.Select.extend({
  getTemplate: function() {
    return this.schema.readonly ? this.constructor.readonlyTemplate : this.constructor.template;
  }
  (...)
  template: (...),
  readonlyTemplate: (...)
});

Perhaps it would be even nicer to always have this getTemplate, template, readonlyTemplate in all editors so it becomes easily overridable. Maybe some people would like to show the readonly text editor not as a deactivated text input but rather as a label or something else.

@alemangui
Copy link
Contributor

Here's an idea #452

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants