How to disable all form_for input fields in Ruby on Rails app?

前端 未结 3 2106
故里飘歌
故里飘歌 2021-01-05 00:54

I am trying to DRY up my Rails application a bit, so I would like to render a form in my show view but disable all input fields.

// sho         


        
3条回答
  •  南方客
    南方客 (楼主)
    2021-01-05 01:01

    You can use stylesheets for this thing.

    The show action might be in controller say 'Project', hence you might be having a file in stylesheets with the name of your controller.

    Now enclose your form in show.html.erb in a div, and give it a unique id ,say 'disable_input', that you wont be giving to any element in any page.

    Now disable all input fields in you css under this div. You can write it like this..

    disable_input input{
    # whatever you want to do
    }

    Hence no need to code.

提交回复
热议问题