I would like to have a field that accepts U.S. dollar amount. I installed the module: https://www.drupal.org/project/currency. Structure > content type > I do not see a field type "Currency". I am not sure how I can add a field to accept USD amount.

How can I add the price field to the content type?

  • Hi, what do you need it for? If you just need to display some dollar amounts you can create a decimal field and then change display output to have $ prefixed. – Japo Domingo May 15 '17 at 4:15
  • I need it for a real estate site. I like to add a price field for the house value. Currency module I installed might be for a bigger project. I will have to do some research on how to add a decimal field. Thanks. – learn4ever May 16 '17 at 4:56
  • Are you using drupal 7 or 8? Ill modify my answer based on which version youre on. – Japo Domingo May 16 '17 at 11:09

So to add a decimal field.

  • edit your content type.
  • manage fields
  • add new field
  • select Decimal from the Field Type dropdown.
  • Click the 'Save' button
  • Change 'Scale' to 2. These are the cents.
  • Click the 'Save field settings' button.
  • In the Prefix field add '$'.
  • Click the 'Save settings' button
  • Thanks. Drupal 7. I did not see number field. I see integer field. I added integer field then widget (decimal > text field) > saved it. Where do I specify 2 decimal places? I also did not understand this part "To prefix a $ to the display value you may need to add a template_preprocess_field and add a #prefix to the field." – learn4ever May 19 '17 at 1:11
  • Drupol, I've updated the instructions. I updated the step by step while actually creating my own field. – Japo Domingo May 19 '17 at 3:56
  • I don't have decimal field type. I need to install another module to see decimal field type? – learn4ever May 21 '17 at 4:31
  • Nope. It's a default field. api.drupal.org/api/drupal/… Be sure to update drupal core. – Japo Domingo May 21 '17 at 7:03
  • @JapoDomingo What if we want to show the currency symbol depending on the user country? Also, how to show /hr or fixed prices? – Umair May 4 '18 at 6:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.