16

I want to stop people adding or editing Page Layout from inside a sub form. Basically I want to turn off the buttons in the below screenshot:

enter image description here

Am I able to do this, or do I have to turn off adding and editing on the entire Page Layout model globally?

koosa
  • 2,966
  • 3
  • 31
  • 46

4 Answers4

31

Probably a bit late but you can use inline_add and inline_edit.

Example:

  field :profile do
    inline_add false
    inline_edit false
  end
Mohammad AbuShady
  • 40,884
  • 11
  • 78
  • 89
clarif
  • 476
  • 4
  • 7
0

Use button_to with :disabled => true option

alex
  • 3,682
  • 3
  • 21
  • 22
0

Maybe not the cleanest solution... anyway here's what i did. Created an alternative partial copying the original one and stripping off the links related to "add new" and "edit". Then I configured the field like this.

  field :operator_user do
    partial "form_filtering_select_no-relations"
    def selected_id
      @bindings[:object]['operator_user_id']
    end
  end

The partial expects a method called "selected_id" to be there and return the id used to build the relation.

user1170896
  • 719
  • 1
  • 7
  • 19
-2

Supposing you are talking about authorizing a specific type of user to "see" the buttons you can go with the cancan gem.

code-gijoe
  • 6,949
  • 14
  • 67
  • 103