Jump to content

Weights & measures fieldtype?


MarkE
 Share

Recommended Posts

I've been looking around for a fieldtype that can handle weights and measures but, rather surprisingly, can't seem to find anything.

What I have in mind is a field that essentially comprises 2 elements - a (float) value and a (dropdown) measure (e.g. lbs, kg). It would also have an associated standard unit (usually an SI unit, I guess), which might or might not be in the dropdown, and each measure option would have a conversion factor to the standard unit. The value would be stored in the database as standard units. The measure options, standard unit and conversions would be specified in the input/details for the field, along with a default measurement option; these could also be set via API. If a user changes the measurement option in the dropdown, then the value would be amended accordingly (via AJAX).

Is it possible to use the Combo ProField for this pupose (I don't have ProFields)? 

Would it be desirable to build a new Fieldtype module for this? Or is there a better way of achieving the same end?

Link to comment
Share on other sites

15 hours ago, MarkE said:

Would it be desirable to build a new Fieldtype module for this? Or is there a better way of achieving the same end?

I'd say that building a custom fieldtype + inputfield would be the best option ?

Link to comment
Share on other sites

  • 2 weeks later...

OK - I did this and it seems to work OK. @teppowas rather quick off the mark with the PW weekly report - I still have to add a lot of units and do some tidying (and remove debugging lines in case people don't have Tracy!). I will also add some notes about what I learnt doing this as the existing tutorials (such as @bernhard's) don't seem to cover fieldtypes which use the database.

Support thread started at 

 

  • Like 3
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...