Skip to content
This repository

making attr_readonly fields disabled #877

Closed
comboy opened this Issue · 4 comments

2 participants

Kacper Cieśla Justin French
Kacper Cieśla
comboy commented

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.

Justin French
Owner

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.

Kacper Cieśla
comboy commented

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.

Justin French
Owner

@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?

Kacper Cieśla

@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
Something went wrong with that request. Please try again.