In Place Editor options

I want my in place editor to be a textarea instead of a textfield.
Therefore
I am doing the following:

controller:
in_place_edit_for :event, :notes

view:
<%= in_place_editor_field :event, :notes, :rows => 5 %>

The method signature for in_place_editor_field is (object, method,
tag_options = {}, in_place_editor_options = {}). I’m a Ruby newbie but I
understand that the last two hashes will be combined into one, so I
don’t
have to explicity have an empty {} in there. According to the source,
in_place_editor_field calls in_place_editor passing in the options hash.
in_place_editor should pass along the ‘rows’ argument to the
Ajax.InPlaceEditor javascript function. It looks like it should work
judging
by the source, but I still get only 1 row. I tried some of the other
options, such as :okay_text and :cancel_text which don’t work either. Am
I
missing something?

Thanks!
Shane

On 11/16/05, Shane V. [email protected] wrote:

I’m a Ruby newbie but I
understand that the last two hashes will be combined into one, so I don’t
have to explicity have an empty {} in there.

This isn’t true. Arguments which look like key => value pairs will be
collected into a single Hash if now bracketing is given, but this
single hash will be used for the tag_options parameter. For example:

in_place_editor_field(arg1, arg2, :key1 => val1, :key2 => val2, :key3
=> val3)

is the same as

in_place_editor_field(arg1, arg2, {:key1 => val1, :key2 => val2,
:key3 => val3})

… so the in_place_editor_options will be given the default value of
an empty hash. If you want to pass anything for the
in_place_editor_options parameter, you need to be explicit with your
Hash brackets, i.e.

in_place_editor_field(arg1, arg2, {:key1 => val1, :key2 => val2},
{:in_place_option => val3})

So, in your example

<%= in_place_editor_field :event, :notes, :rows => 5 %>

The paramter {:rows => 5 } is actually a part of the tag_options, when
as far as I can tell, it should be in the in_place_editor_options. You
want something like this (formatted weirdly here for comments):

<%= in_place_editor_field(:event, :notes,
{},
# tag_options
{:rows => 5})

in_place_editor_options

%>
  • james

James…

Thanks! That worked. I actually did try putting in the brackets before
since
I figured, as you did, that all key => value pairs would be collected
into a
the tag_options hash. However I tried it with the “cancel_text”
argument,
which still doesn’t seem to work. So thats why I assumed it wouldn’t
work
with “rows.”

I also found a minor bug in the 0.14.3 version of the Rdocs. The
“ok_text”
argument should actually be “save_text” since that is what the code is
looking for. Didn’t check to see if this was logged yet.

Appreciate the help.

Shane