Skip to content

Instantly share code, notes, and snippets.

Created March 25, 2011 14:30
Show Gist options
  • Save anonymous/886919 to your computer and use it in GitHub Desktop.
Save anonymous/886919 to your computer and use it in GitHub Desktop.
new.erb
<%= error_messages_for 'typeCustomFields' %>
<div class="box">
<p>
<%= f.text_field :descrizione, :label=>l(:label_descrizione), :required => true-%>
</p>
<p>
<%= f.text_field 'figlia_di', :label=>l(:label_parent) -%>
</p>
<p>
<%= f.text_field :riferimento, :label=>l(:label_riferimento), :required => true %>
</p>
</div>
<h2><%=l(:label_type)%></h2>
<% labelled_tabular_form_for :type, @type, :url => {:action => 'create' } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_create) %>
<% end %>
class TypeCustomFields < ActiveRecord::Base
validates_presence_of :descrizione
validates_presence_of :riferimento
def self.findAll
TypeCustomFields.find(:all)
end
end
class TypeCustomFieldsController < ApplicationController
before_filter :get_type_new
def get_type_new
@type = TypeCustomFields.new
end
def new
@type = TypeCustomFields.new
end
def create
@type = TypeCustomFields.new(params[:typeCustomFields])
if @type.save
flash[:notice] = l(:notice_successful_create)
redirect_to :controller => 'type_custom_fields', :action => 'settings'
else
render :action => 'new'
end
end
def edit
if request.post? and @type.update_attributes(params[:descrizione]) and @type.update_attributes(params[:riferimento])
flash[:notice] = l(:notice_successful_update)
redirect_to :controller => 'type_custom_fields', :action => 'settings'
end
end
def settings
respond_to do |format|
format.html { render :template => ' settings/redmine_linked_custom_fields_settings', :layout => !request.xhr? }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment