0

I'm just wondering how to add a new option to the webform submission formatters for a specific element? is it driven by the field API? webform date field submission formatter

1 Answer 1

1

What you have in that list are date formats. You can manage those, including adding new ones, at /admin/config/regional/date-time.

enter image description here

3
  • The question is, how do I do that programmatically? I don't want it's just for the date field, how about for other types of fields
    – heshanlk
    Commented Aug 31, 2018 at 13:04
  • Each is different - have a look at the different classes in webform/src/Plugin/WebformElement/*.php to get an idea of where each element type gets its data from. There isn't a universal method, so you'll need to approach each differently. For your given example, look at DateBase::getItemFormats(), which uses DateFormat::loadMultiple() directly, and doesn't ask the rest of the system for input. This makes sense, because when rendering that value, it needs to know that it has a valid date format that the system knows about. If you were able to add one that wasn't a valid date format...
    – Clive
    Commented Aug 31, 2018 at 14:28
  • ...it would break on render. So the values are gathered from an existing known API, and new values need to be added to that API's storage - Webform only has an outside view of them
    – Clive
    Commented Aug 31, 2018 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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