Carbon-fields: Complex Field: Show field value on Entry

Created on 17 May 2016  ·  8Comments  ·  Source: htmlburger/carbon-fields

It would be usefull to show a (user defined) fields value on an entry when it's collapsed.

cf-complex-label

feature

Most helpful comment

Thanks for taking the initiative!

What do you think about the idea of using an underscore template? I was thinking on the case where there is a name and surname field and we want to show both of them on the header. Something like:

Field::make('complex', 'staff')->add_fields([
    Field::make('text', 'name'),
    Field::make('text', 'surname'),
])->set_header_template('{{ surname }}, {{ name }}'); // or set_title, set_header…

It would be nice also to support images and other data types… but I'm not sure how doable and desirable it is as a feature. I can imagine use cases where having the image in the header can be a nice touch, but if the JS API it's not developed I understand that it can be quite a work.

Just asking… tell me if I can help somehow. ^_^

All 8 comments

Indeed, it would be cool to be able to define an underscore template so that some logic can be embedded.

Folks, this sounds like a really useful feature.

Care to provide a prototype implementation, and/or a vision of how you'd expect it to be defined from the developer's perspective?

I created a prototype for this here: https://github.com/tschortsch/carbon-fields/commit/f0beb59bd5403374645c5becf17c4a08b7277d8b. Right now I just tested it with Fields of type Text.
It has to be checked / enhanced for all the other field types. I could do that but first I wanted to know if I go in the right direction?

Thanks for taking the initiative!

What do you think about the idea of using an underscore template? I was thinking on the case where there is a name and surname field and we want to show both of them on the header. Something like:

Field::make('complex', 'staff')->add_fields([
    Field::make('text', 'name'),
    Field::make('text', 'surname'),
])->set_header_template('{{ surname }}, {{ name }}'); // or set_title, set_header…

It would be nice also to support images and other data types… but I'm not sure how doable and desirable it is as a feature. I can imagine use cases where having the image in the header can be a nice touch, but if the JS API it's not developed I understand that it can be quite a work.

Just asking… tell me if I can help somehow. ^_^

@tschortsch: I believe forcing it wouldn't be a good idea.

@doup: I really like that suggestion. We should implement it :+1:

The feature has been implemented here: https://github.com/htmlburger/carbon-fields/pull/35.
Props @m1r0.
Documentation coming soon, as well.
@tschortsch, @doup, thanks for the great ideas, folks :+1:

Wow, thanks! Looks really neat, I'll test it next week in a couple of projects. 👍 👍 👍

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jonwaldstein picture jonwaldstein  ·  3Comments

leurdo picture leurdo  ·  3Comments

bjoernhasse picture bjoernhasse  ·  3Comments

dmhendricks picture dmhendricks  ·  3Comments

kaleidoscopique picture kaleidoscopique  ·  3Comments