joomla/joomla-cms — pull request #4667 by itbra (2014-10-14 14:12:43+00:00)
Title: JForm::setFieldAttribute() to merge rather than replace

i found JForm::setFieldAttribute method to not evaluate if passed in values for a specific attribute shall be merged into existing values or instead replace them, which forces one to write longer setFieldAttribute() statements just not to loose existing values. For example:

```
$form->setFieldAttribute(
'description',
'labelclass',
$form->getFieldAttribute('description', 'labelclass', '', 'params') . '
new1 new2 new3 ...',
'params'
);
```

Note the 3rd param. This is pretty long, isn't it? And since it is not always only one single attribute that might be passed in, this param might become much longer. Wouldn't you agree that it is much easier to write:

```
$form->setFieldAttribute(
'description',
'labelclass',
'new1 new2 new3 ...',
'params'
);
```

We can easily shorten it by changing the related JForm method to evaluate this circumstance and either merge or replace the related attribute.

There already is an [entry at the joomlacode bug tracker](http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_id=8103&tracker_item_id=31493) along with detailed testing instructions.