
=form_for( [:portlet, @garde_content], :remote => true) do |f|
	=hidden_field_tag "block_id", params[:block_id]
	=hidden_field_tag "portlet_id", params[:portlet_id]
	=hidden_field_tag "position", params[:position]

	
	%table
		%tr
			%td=f.text_area :column_1, :class => "common_editor"
			%td=f.text_area :column_2, :class => "common_editor"
			%td=f.text_area :column_3, :class => "common_editor"
			%td=f.text_area :column_4, :class => "common_editor"
			%td
		=f.fields_for :garde_lines do |f|
			=render :partial => "portlet/garde_contents/garde_line_fields", :locals => {:f => f }
	
	
	
			
	
		
	%p= link_to_add_fields "Ajouter une ligne", f, :garde_lines 
	=f.submit "Sauvegarder"






:javascript
	
	$("textarea.common_editor").each(function() {

	common_tiny_mce($(this));
	});
	
	function remove_fields(link) {
	$(link).prev("input[type=hidden]").val("1");
	$(link).closest(".field").hide();
	return false;
	};

	function add_fields(link, association, content) {
	
	var new_id = new Date().getTime();
	var regexp = new RegExp("new_" + association, "g")
	$(link).closest("form").children('table').append(content.replace(regexp, new_id).replace('<tr', "<tr class='new_field field'"));


	$('.new_field textarea.common_editor').each(function() {

	common_tiny_mce($(this));
	});
	$('.new_field').removeClass("new_field")
	
	return false;
	};