Jump to content

Fieldtype vs. Inputfield - What's the difference?


steveooo
 Share

Recommended Posts

Hello guys,

I want to write my first module and I read a lot about fieldtypes and inputfields.

I really don't get the difference between the two. I hope someone can explain it to me!

Maybe it is easier to tell what I want to do and you could tell me what roles fieldtypes and inputfields have with this module I want to create.

I want to create a field that consists of multiple fields (text, textarea). It should be a field that wraps some other fields, so I don't have to install 10 different fields every time.

How would I achieve this in regards of fieldtypes and inputfields (and data storage)?

Thanks!

Link to comment
Share on other sites

Hello,

I read that, but still I do not really get the difference. It would be nice if someone would explain it to me with my example. For example this module is a SEO module (I know MarkupSEO!) that adds a own 'seo_stuff' field to every page. 'seo_stuff' consists of multiple fields like 'seo_description' as textarea and 'seo_keywords' as string. Just a test project for better understanding.

Link to comment
Share on other sites

A good place to start reading would also be the Map Marker field module, which Ryan created as an example.

In short:

The Fieldtype is responsible for taking care of saving to and loading from the database as well as sanitizing values, creating the database table(s) and assembling the correct database query from a selector.

The Inputfield renders the input form elements and processes form input.

InputfieldMapMarker generates its input elements manually in the render method, but you can also use InputfieldXXX modules (like it does in ___getConfigInputfields) and add those to an InputfieldWrapper, then render that.

  • Like 5
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...