I would like to create a custom form element for Ruby on Rails 3 and package it as a gem. I am coming from a PHP (Zend Framework) background, where it is easy to create custom form elements to use within your application. Being new to Ruby on Rails, I don't know how to start, where to put my code, and which classes to extend. Can you please point me in the right direction? This is the code that I want to end up with:

```
<%= form_for(@model) do |f| %>
  <div class="field">
    <%= f.label :field_name %><br />
    <%= f.my_custom_element :field_name %>
  </div>
<% end %>

```

...which will generate some HTML like this:

```
<div class="field">
  <label for="model_field_name">Notes</label><br>
  <input type="text" name="model[field_name][field1]">
  <input type="text" name="model[field_name][field2]">
  <input type="text" name="model[field_name][field3]">
</div>

```

..then when the user submits the form, there will be some custom validation, and custom logic to stitch the fields together again into one field before Rails saves the data to the database.

How can I create this custom form element to do this? (By the way, I've been calling it a "custom form element" because that's what it's called in Zend Framework. If Rails has a different name for this, please correct me so I can have an easier time finding information on this subject.)