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

making attr_readonly fields disabled #877

Closed
comboy opened this issue Jul 30, 2012 · 4 comments
Closed

making attr_readonly fields disabled #877

comboy opened this issue Jul 30, 2012 · 4 comments

Comments

@comboy
Copy link

comboy commented Jul 30, 2012

Hi,

What do you think about making fields listed as attr_readonly disabled in edit form by default? I'd gladly try to contribute this, I just wanted to check if it's indeed a good idea.

@justinfrench
Copy link
Member

I don't think we need any more magic or any more reasons to use the quick form syntax :)

In projects where I've needed a disabled field (I use them quite a lot, actually), I implemented a DisabledStringInput (subclassed from Formtastic::Inputs::StringInput and simply called :as => :disabled_string explicitly on the inputs.

@comboy
Copy link
Author

comboy commented Jul 31, 2012

I'm all against magic, but whole f.input :foo syntax seems to be about magic and not telling it, what it can already get from the model.

Without this, there's redundancy between model and view where you do this like you said or something like f.input :name, input_html: {disabled: f.object.persisted?} that I have. Without this behavior seems a bit unnatural, you have a normal form, you submit it, and data is not updated. Why letting user edit something that cannot be updated?

Sorry that I keep asking, I very much respect your decision since all previous ones lead to very nicely designed library, please just think about it some more when you have a sec.

@justinfrench
Copy link
Member

@comboy agreed, there's plenty of magic, my argument is that I'm not really interested in more magic without a seriously strong rationale. I'll be removing magic in upcoming versions :)

I just can't see this being a major pain point for the average developer. Can you get specific about your use case?

@comboy
Copy link
Author

comboy commented Aug 2, 2012

@justinfrench Yes I guess most people just don't display these readonly fields in edit form.

My use case is mostly through activeadmin.

Thanks for taking time to explain and good luck fighting magic :)

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

No branches or pull requests

2 participants