The short version of my request...

This is a [modified] snip from the admin page of my site at "/admin/structure/types/manage/sell-line-item/display/default".

Looking at the BD documentation, it appears to me that this might be accomplished by adding two booleans to the data structure, and some code to the functions:

  • function number_field_formatter_info()
  • function number_field_formatter_settings_form()

...and others, found in the number.module.

Anybody else think that this would be a cool addition to core?

Most helpful answers

That's great news @ericfoy. It is always a great feeling when you get your first module in.  I don't have a need for it at present, but some of the ideas I have could well use such a model.

What is even greater is that you built this from scratch rather than it being a port.  What you should really put in your credits section is:

Created for Backdrop CMS by Eric Foy

Link to you.  It's also perfectly acceptable to link to your company page where you mention that is sponsored by your company (Github automatically adds 'rel="nofollow"' but it gives the opportunity for people to find your company.  What you've done is a great contribution to Backdrop CMS so don't undersell yourself. 

@ericfoy, one quick way to deal with this on a specific field is to create a custom module that implements hook_field_attach_view_alter()  and modify the display value there. This solution will work for specific fields or field types, though, and won't give you the flexibility to specify which fields through the UI.

Alternatively, and while this is discussed in the issue queue, you could create a custom formatter, which involves creating a custom module that implements (at least) the following hooks:

hook_field_formatter_info() - defines the formatter
hook_field_formatter_settings_form() - provides your settings form
hook_field_formatter_settings_summary() - provides a settings summary
hook_field_formatter_view()  - actually performs the trimming

You can find many examples of custom formatters online, and even including one in the Field Example (Examples module)

Comments

> Anybody else think that this would be a cool addition to core?

@ericfoy - I hate to suggest this, because I know that it starts to get a bit confusing, BUT if you are interested in suggesting new features for core, you MIGHT want to visit the core issue queue for Backdrop CMS directly.

https://github.com/backdrop/backdrop-issues/issues

It's fine to post these issues and suggestions here. One of us will probably move your idea to the core issue queue (if you don't). BUT, if you are so inclined to participate, the interesting discussions about what MIGHT go into core happen in that space and it's perfectly acceptable (and encouraged) for folks like yourself to post messages there, including feature requests.

---------------

Have you looked for a contrib module that might meet your needs?

@ericfoy, one quick way to deal with this on a specific field is to create a custom module that implements hook_field_attach_view_alter()  and modify the display value there. This solution will work for specific fields or field types, though, and won't give you the flexibility to specify which fields through the UI.

Alternatively, and while this is discussed in the issue queue, you could create a custom formatter, which involves creating a custom module that implements (at least) the following hooks:

hook_field_formatter_info() - defines the formatter
hook_field_formatter_settings_form() - provides your settings form
hook_field_formatter_settings_summary() - provides a settings summary
hook_field_formatter_view()  - actually performs the trimming

You can find many examples of custom formatters online, and even including one in the Field Example (Examples module)

Okay, now you've got me goin'... I think I have everything I need to create my desired functionality. And what a fantastic learning tool this will be for me!

That's great news @ericfoy. It is always a great feeling when you get your first module in.  I don't have a need for it at present, but some of the ideas I have could well use such a model.

What is even greater is that you built this from scratch rather than it being a port.  What you should really put in your credits section is:

Created for Backdrop CMS by Eric Foy

Link to you.  It's also perfectly acceptable to link to your company page where you mention that is sponsored by your company (Github automatically adds 'rel="nofollow"' but it gives the opportunity for people to find your company.  What you've done is a great contribution to Backdrop CMS so don't undersell yourself.