I'd like to apply formatting to a contenttype displayed in a select list. The current comma based (https://docs.bolt.cm/3.3/fields/select#populating-the-values-from-a-contenttype) approach is not sufficient for me. I have two main use cases:
More complex formatting of multiple fields
I have periods which start at a specific date and end at a specific date (i.e 1-10-2017 till 1-04-2018). I'd like to format this as "<Name of period> (2017-2018)".
Concat several fields
Although this is possible with the current comma separated method, I have several cases where i'd like to have a different separator than '/'. Secondly the current method is unable to handle optionally empty fields (which like is a bug on it's own)
Solutions i'm considering:
Make a pull-request and add a format parameter
However, I started digging in the code, and the code that handles this behaviour is located at: https://github.com/bolt/bolt/blob/3.3/src/Form/Resolver/Choice.php#L139. On top of the class there is a comment stating: "@internal DO NOT USE. Will be replaced circa Bolt 3.5". So will you accept a pull request over here?
Secondly which approach do you want to use here? Something in line with the relationship format option? Multi-contenttype select-list seem to be coming up (https://github.com/bolt/bolt/pull/6299), which makes formatting a bit more complex. For that case I suggest something like this:
contenttypename1: <format string here>
contenttypename2: <format string here>
Add the option for expression based readonly fields
As asked/implied by https://discuss.bolt.cm/d/666-can-contenttype-title-be-generated-based-on-other-field-values, another viable option would be to add an 'Expression' option to every field. This Expression can be a twig formatting line, or a Symfony2 ExpressionLanguage (https://symfony.com/doc/current/components/expression_language.html) expression. This field can than be calculated based on the contents of the other fields of the content type (local expression, no options to perform queries).
Would it be possible to create this as an extension potentially? Or does this need to added to the core? I could not find any documentation on how to write an extension that adds a YAML property to existing fieldtypes, and then performs its action on it (like the decorator pattern).
Create an extension with a derived version of the Select
Create an extension that extends/implements select field. However i'm a bit hesitant for this option, since it has higher maintainability efforts.
Relationships can apply complex formatting rules in their select-box (https://docs.bolt.cm/3.3/contenttypes/relationships#), however they can not be made mandatory? Another minor issue is that i'd like call the tab differently :-)
Hope you can provide me with some answers