Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

field (css class) defaults+ #731

Merged
merged 3 commits into from
Dec 1, 2024

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