Skip to content

Conversation

@rudiedirkx
Copy link
Collaborator

class_append didn't work for field types with specific config/classes.

Config:

return [
	'defaults' => [
		'field_class'         => 'form-control',

		'checkbox' => [
			'field_class' 		=> 'form-check-input',
		],
	],
];

Add field:

$this->add('mycheckbox', 'checkbox', [
	'label' => "Wadever",
	'attr' => ['class_append' => 'custom-checkbox'],
]);

That <input> would have class="form-check-input", not form-check-input custom-checkbox, because setDefaultClasses() (with form-check-input) happened after prepareOptions() (with class_append/custom-checkbox), so the custom classes was added and then immediately overwritten.

@rudiedirkx rudiedirkx merged commit b01ef09 into kristijanhusak:master Dec 1, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant