<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>This Entangled Bank: use multiple instances of FCK Editor when editing a Rails collection</title>
  <subtitle type="html">may contain traces of knowledge</subtitle>
  <id>tag:entangledbank.co.uk,2005:Typo</id>
  <generator version="4.0" uri="http://www.typosphere.org">Typo</generator>
  <link href="http://entangledbank.co.uk/xml/atom/article/19/feed.xml" rel="self" type="application/atom+xml"/>
  <link href="http://entangledbank.co.uk/articles/2007/05/09/use-multiple-instances-of-fck-editor-when-editing-a-rails-collection" rel="alternate" type="text/html"/>
  <updated>2007-05-10T01:07:15+01:00</updated>
  <entry>
    <author>
      <name>Ed</name>
    </author>
    <id>urn:uuid:cf6795c2-b665-4aac-8ce9-921257974661</id>
    <published>2007-05-09T00:38:00+01:00</published>
    <updated>2007-05-10T01:07:15+01:00</updated>
    <title type="html">use multiple instances of FCK Editor when editing a Rails collection</title>
    <link href="http://entangledbank.co.uk/articles/2007/05/09/use-multiple-instances-of-fck-editor-when-editing-a-rails-collection" rel="alternate" type="text/html"/>
    <category term="rails" scheme="http://entangledbank.co.uk/articles/tag/rails"/>
    <summary type="html">&lt;p&gt;Scott Rutherford has kindly packaged up a Rails helper for the &lt;span class="caps"&gt;FCK&lt;/span&gt; Editor as a plugin. You can find it &lt;a href="http://blog.caronsoftware.com/articles/category/fckeditor-plugin"&gt;here&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;I was stumped for a while as I wanted to use multiple instances of the editor in a form used to edit a collection of objects, but figured it out with a little help from Scott.&lt;/p&gt;</summary>
    <content type="html">&lt;p&gt;Scott Rutherford has kindly packaged up a Rails helper for the &lt;span class="caps"&gt;FCK&lt;/span&gt; Editor as a plugin. You can find it &lt;a href="http://blog.caronsoftware.com/articles/category/fckeditor-plugin"&gt;here&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;I was stumped for a while as I wanted to use multiple instances of the editor in a form used to edit a collection of objects, but figured it out with a little help from Scott.&lt;/p&gt;&lt;p&gt;I was using the syntax:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;&amp;lt;%= text_field(&amp;quot;product[]&amp;quot;, &amp;quot;name&amp;quot;, :size =&amp;gt; 60) %&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

successfully on other fields but trying:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;&amp;lt;%= fckeditor_textarea(&amp;quot;product[]&amp;quot;, 'description', ... %&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;gave me the error:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;(eval):1:in `[]': wrong number of arguments (0 for 1)&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

In order to get &lt;span class="caps"&gt;HTML&lt;/span&gt; in the correct form:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;&amp;lt;textarea id='product_3893_description_editor' 
 name='product[3893][description]'&amp;gt;blank&amp;lt;/textarea&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

it was necessary to pass the product ID to Scott&amp;#8217;s helper as an additional argument:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;&amp;lt;%= fckeditor_textarea_multi( &amp;quot;product&amp;quot;,  &amp;quot;description&amp;quot;, 
@product.id, { ...}) %&amp;gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

and tweak the helper in fckeditor.rb:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;fckeditor_textarea_multi&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;object&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="ident"&gt;field&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="ident"&gt;new_arg&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="ident"&gt;options&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;{})&lt;/span&gt;
   &lt;span class="punct"&gt;...&lt;/span&gt; &lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="ident"&gt;snip&lt;/span&gt;&lt;span class="punct"&gt;]&lt;/span&gt; &lt;span class="punct"&gt;...&lt;/span&gt;  
   &lt;span class="ident"&gt;inputs&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;&amp;lt;textarea id='&lt;span class="expr"&gt;#{id}&lt;/span&gt;' &lt;span class="expr"&gt;#{cols}&lt;/span&gt; &lt;span class="expr"&gt;#{rows}&lt;/span&gt;  
   name='&lt;span class="expr"&gt;#{object}&lt;/span&gt;[&lt;span class="expr"&gt;#{new_arg}&lt;/span&gt;][&lt;span class="expr"&gt;#{field}&lt;/span&gt;]'&amp;gt;
   &lt;span class="expr"&gt;#{value}&lt;/span&gt;&amp;lt;/textarea&amp;gt;&lt;span class="escape"&gt;\n&lt;/span&gt;&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
   &lt;span class="punct"&gt;...&lt;/span&gt; &lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="ident"&gt;snip&lt;/span&gt;&lt;span class="punct"&gt;]&lt;/span&gt; &lt;span class="punct"&gt;...&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content>
  </entry>
</feed>
