Class: Backend::Forms::FieldsController

Inherits:
BaseController
  • Object
show all
Includes:
Concerns::Backend::PositionableController, Concerns::Backend::TranslatableController, Concerns::PaginationController
Defined in:
app/controllers/backend/forms/fields_controller.rb

Instance Method Summary collapse

Methods included from Concerns::PaginationController

#page_number, #paginate, #per_page

Methods included from Concerns::Backend::PositionableController

#update_position

Methods included from Concerns::Backend::TranslatableController

#update_translation

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/backend/forms/fields_controller.rb', line 16

def create
  @field = @form.fields.new(allowed_params)

  if @field.save
    redirect_to edit_translation_backend_form_field_path(@form, @field, locale),
      notice: translate_notice(:added, :form_field)
  else
    render :new
  end
end

#destroyObject



36
37
38
39
40
# File 'app/controllers/backend/forms/fields_controller.rb', line 36

def destroy
  @field.destroy
  redirect_to backend_form_fields_path(@form),
              notice: translate_notice(:deleted, :form_field)
end

#newObject



12
13
14
# File 'app/controllers/backend/forms/fields_controller.rb', line 12

def new
  @field = @form.fields.new
end

#updateObject



27
28
29
30
31
32
33
34
# File 'app/controllers/backend/forms/fields_controller.rb', line 27

def update
  if @field.update_attributes allowed_params
    redirect_to backend_form_fields_path(@form),
                notice: translate_notice(:edited, :form_field)
  else
    render :edit
  end
end