1

Does anybody know if there is a module to make labels of fields selectable, for instance Field course:

  • Abc in DCT
  • 123 today
  • listening pop

so if I select 123 today, in my content display I would have:

course: 123 today

but I would like to change course: by workshop: at the visualization of the content and have "course" for the other two (Abc in DCT and listening pop). So maybe there is a module that allows label selection, I haven't find it yet.

1

3 Answers 3

0

You'll have to make a custom field formatter with a settings form where you select the label and then output it accordingly.

Like in this tutorial about field formatters

2
  • Thanks for your answer, but if I do not get wrongly, this offers an alternate label, what I need is a list of lables to choose, and this available at the moment of content cretion, so if the content creator has to add in the courses field a course, he should be able to label it either course or workshop... Commented May 22, 2015 at 15:47
  • This is also possible, you'll just have to add the list as a part of the field input. Probably by adding an entire new custom field type. Commented May 23, 2015 at 14:18
0

There are a couple of modules you can try:

Besides these modules, you can do it in code using custom formatters like Suranga said or implementing theme preprocessors.

2
  • Thanks for your answer, but these modules offer an alternate label, what I need is a list of lables to choose, and this available at the moment of content cretion, so if the content creator has to add in the courses field a course, he should be able to label it either course or workshop... Commented May 22, 2015 at 15:48
  • OK, then I misunderstood your question, sorry. Commented May 23, 2015 at 21:48
0

What you are describing is actually two fields. One is the "label" (a textfield limited to a select number of otpions, or a taxonomy term), the other is the description.

You can do this a bunch of different ways, depending on your needs:

  • Entity References (allows multiple)
  • Field Collections (allows multiple)
  • Field Groups/Fieldsets (only one)

If I understand correctly, you want to be able to click on the description and the label will automatically show up. To do that, I would predefine the labels and descriptions by creating them in a separate entity. Then, you could select these from a list of descriptions by using the Entity Reference module.

1
  • Thanks for your answer, I started to look for a how to, do you have any link already to a how-to, it is just that I'm not an expert, sorry. Commented May 23, 2015 at 8:16

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