Class: Admin::FormFieldGroupsController

Inherits:
AdminController
  • Object
show all
Defined in:
app/controllers/admin/form_field_groups_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



21
22
23
24
25
26
27
28
29
# File 'app/controllers/admin/form_field_groups_controller.rb', line 21

def create
  @form_field_group = FormFieldGroup.new(params[:form_field_group])
  @form_field_group.system_id = _sid
  if @form_field_group.save
    redirect_to [:admin, @form_field_group], :notice => "Successfully created field group"
  else
    render :action => 'new'
  end
end

#destroyObject



45
46
47
48
49
50
# File 'app/controllers/admin/form_field_groups_controller.rb', line 45

def destroy
  @form_field_group = FormFieldGroup.find_sys_id(_sid, params[:id])
  form_id = @form_field_group.form_id
  @form_field_group.destroy
  redirect_to "/admin/form_field_groups?form_id=#{form_id}", :notice => "Successfully delete field group"
end

#editObject



31
32
33
34
# File 'app/controllers/admin/form_field_groups_controller.rb', line 31

def edit
  @form_field_group = FormFieldGroup.find_sys_id(_sid, params[:id])
  @form = @form_field_group.form
end

#indexObject



3
4
5
6
7
# File 'app/controllers/admin/form_field_groups_controller.rb', line 3

def index
  @form = Form.sys(_sid).where(:id=>params[:form_id]).first
  redirect_to "/admin/forms", :notice=>"Can't find that field group" and return unless @form
  @form_field_groups = @form.form_field_groups
end

#newObject



14
15
16
17
18
19
# File 'app/controllers/admin/form_field_groups_controller.rb', line 14

def new
  @form = Form.sys(_sid).where(:id=>params[:form_id]).first
  @form_field_group = FormFieldGroup.new
  @form_field_group.form = @form
  @form_field_group.order_by = @form.form_field_groups.last.order_by + 100 rescue 100
end

#showObject



9
10
11
12
# File 'app/controllers/admin/form_field_groups_controller.rb', line 9

def show
  @form_field_group = FormFieldGroup.find_sys_id(_sid, params[:id])
  @form = @form_field_group.form
end

#updateObject



36
37
38
39
40
41
42
43
# File 'app/controllers/admin/form_field_groups_controller.rb', line 36

def update
  @form_field_group = FormFieldGroup.find_sys_id(_sid, params[:id])
  if @form_field_group.update_attributes(params[:form_field_group])
    redirect_to [:admin, @form_field_group], :notice  => "Successfully updated field group"
  else
    render :action => 'edit'
  end
end