I have defined custom Integer field in commerce product entity. I would like to achieve, that if field should be displayed on the website (i.e. in some view) and if field value == -1, then text string t('Unlimited') should be displayed instead of field value.

Is it possible to change field value before display? I would like to change only output of the field value, not value in database.

I have created field using UI, not programatically, so I think I cannot use many of hooks concerning fields like hook_field_prepare_view.

I don't want to use preprocess function in my theme, because I would prefer solution that will work independent on current theme.

  • do you use fields display in views OR teasers? – milkovsky Jul 8 '13 at 9:19
  • Preprocess functions work equally well in modules as they do in themes; so there's no need to put the logic in a theme – Clive Jul 8 '13 at 9:29

Your Answer

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

Browse other questions tagged or ask your own question.