In-place form editing


#1

Ive been following the rails recipes (great book) and wanted to have a
larger a text field when editing in place.

The chapter it mentions that I can “force the InPlaceEditor to create
either a text field or a field, using the :rows option to
in_place_editor_field( ). Then any value greater than 1 will tell
InPlaceEditor to generate a .” It doesn’t elaborate and Im
not sure on the correct way to write it.

I presume you just have to update the view file only (i might be wrong)

my view is -

<% for column in Contact.content_columns %>

<%= in_place_editor_field :contact, column.name%>

<% end %> <%= link_to ' Back' , :action => ' list' %>

#2

Hello Rob,

2006/4/18, Rob B. removed_email_address@domain.invalid:

<%= in_place_editor_field :contact, column.name%>

The options go after the column, so in your case, you’d do it this way:
<%= in_place_editor_field :contact, column.name, :rows => 2, :cols => 50
%>

If you go to the Rails API at http://api.rubyonrails.com/, you can
find the declaration of #in_place_editor_field, and take it from
there.

Hope that helps !


#3

François Beausoleil wrote:

Hello Rob,

2006/4/18, Rob B. removed_email_address@domain.invalid:

<%= in_place_editor_field :contact, column.name%>

The options go after the column, so in your case, you’d do it this way:
<%= in_place_editor_field :contact, column.name, :rows => 2, :cols => 50
%>

If you go to the Rails API at http://api.rubyonrails.com/, you can
find the declaration of #in_place_editor_field, and take it from
there.

Hope that helps !

Thanks. I thought that would work but the boxes are still one line.


#4

Rob B. wrote:

François Beausoleil wrote:

[…]

The options go after the column, so in your case, you’d do it this way:
<%= in_place_editor_field :contact, column.name, :rows => 2, :cols => 50
%>

[…]

Thanks. I thought that would work but the boxes are still one line.

That’s because in_place_editor_field takes two hashes in its
parameter list. You have to specify which one.

Try this:

<%= in_place_editor_field :foo, :bar, {}, {:rows => 4, :cols => 75} %>

-Drew


#5

It’s unfortunate that the API doesn’t give enough information to
understand this – and a person has to ask on list for answers.

The API:

in_place_edit_for(object, attribute, options = {})

The answer:

<%= in_place_editor_field :foo, :bar, {}, {:rows => 4, :cols => 75} %>

Ben