Closed Integral closed 10 years ago
I don't think there an elegant way of doing this right now as the Hidden editor is treated in a special way. We'd need to generalise the code in src/field.js where it checks if the editor is of the built-in Hidden type. For example, instead of checking if the type is Hidden it could check if the editor has a 'isHidden' property.
On Sun, Oct 19, 2014 at 8:01 PM, Daniel Beilinson notifications@github.com wrote:
Hey!
Just created simple editor for hidden objects (storing objects in hidden input). I'm wonder how could I hide whole field like core's hidden type which is rendered like plain input without any wrappers?
P.S.: Is there any way to see editor type in templates like key, editorId etc?
Reply to this email directly or view it on GitHub https://github.com/powmedia/backbone-forms/issues/424.
Ok, here pull request. Please merge it, it's important in browserify way. Everything works fine. But let's talk about editor type. It would be nice to expose it into field template, so we could build different templates for different field. But currently editor.type contains constructor of editor, so we couldn't send it to template. Maybe we should also create some property here and extract editor type to it? But that's not so easy if someone defined object in schema because we have unnamed constructors... What do you think?
That's merged but note that I've renamed the 'isHidden' field to 'noField' as this can then be used for other editor types too if for some reason only the editor is required.
Yep, thanks. What do you think about passing editor type to templates?
If I understand correctly the easiest way might be to have some property on the editor definition, something like editor.fieldClassName = 'text'
Thanks, yes I could do it. But that's not great way I think... Much better would be storing this value as schema property for all editors. We could do it easily using schema.type if no one will use object reference in schema.
I mean if we'll change this:
schema.type = (_.isString(schema.type)) ? Form.editors[schema.type] : schema.type;
to this:
schema.type = Form.editors[schema.type];
we could do also:
schema.editorType = schema.type
before.
Well, I understand that it's not great to change such kind of things because of compatibility with old versions, but in the other hands it's not great to pass object directly to schema because of after js mangling this will not work.
Hey!
Just created simple editor for hidden objects (storing objects in hidden input). I'm wonder how could I hide whole field like core's hidden type which is rendered like plain input without any wrappers?
P.S.: Is there any way to see editor type in templates like key, editorId etc?