In my project, I needed a button to have a different label than its value. I suspect also others may find this a useful feature.

I just tweaked a line from

$variables['label'] = $element->getProperty('value');


$variables['label'] = $element->getProperty('label') ?: $element->getProperty('value');

so it allows programmers to define

'#value' => 'foo',
'#label' => 'bar',

in the form definition.

#2 allow-different-label-2851655.patch743 bytesjorges
Members fund testing for the Drupal project. Drupal Association Learn more


jorges created an issue. See original summary.

jorges’s picture

Issue summary: View changes
743 bytes
markcarver’s picture

Status: Active » Closed (won't fix)

I'd rather not introduce a non-standard "label" property on button elements when the "title" property already exists. Doing so could become quite confusing. This same kind of functionality can be added to a sub-theme via a preprocess or prerender plugin if absolutely necessary.

jorges’s picture

Sure, you can also use the same code but name the property "title" instead of "label". I just used label because that's what was already used within the template.

And yes, it's all possible to add the functionality via a sub theme – but then it's just more code on the "end-programmer's" side.

Having the code (incl. fallback) within Bootstrap (using "title" if you want) wouldn't seem too confusing to me, and would not break any existing functionality.