Jump to content

Tutorial on creating custom fieldtype and/or inputfield?


theoretic
 Share

Recommended Posts

Hi there! And thanks for Processwire!

Maybe i'm not very attentive but couldn't find any tutorial on creating custom fieldtype with custom inputfield. Would like to make one for selecting color(s) from predefined list of colors. The closest existing match is FieldtypeSelectOptions with InputfieldSelect but i need something different. There's a very good post from @Soma   which is, however, insufficient to begin building my own fieldtype or at least to attach the existing inputfield to an existing field.

Will appreciate any help. Thanks in advance!

Link to comment
Share on other sites

3 hours ago, theoretic said:

creating custom fieldtype with custom inputfield

3 hours ago, theoretic said:

attach the existing inputfield to an existing field

Those two things contradict each other somewhat. If you are creating a new custom fieldtype then there won't be any existing field data until you create your fieldtype module and start using it in pages.

3 hours ago, theoretic said:

but couldn't find any tutorial on creating custom fieldtype with custom inputfield

There is the Events fieldtype and inputfield which was created specifically as a proof-of-concept for developers to learn from. But it extends FieldtypeMulti (each field instance saves/shows multiple repeated items) so that might not suit what you are wanting to do. I don't think Ryan made a similar proof-of-concept for a straight Fieldtype. But in a way all the Fieldtype modules in the core and in the modules directory are a proof-of-concept - find a fieldtype that is broadly similar to what you want to do and check out (borrow from ;)) the code. Also, the documentation for the Fieldtype class will be useful.

Perhaps if you describe exactly what you want the fieldtype/inputfield to do people can give you more suggestions.

  • Like 4
Link to comment
Share on other sites

Some time ago, I started to develop a module that provides a predefined (field settings) list of colors as a supplement to the FieldtypeColor module. Quite expensive and therefore unfortunately remained.

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...