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

Better class addition which preserve previously assigned classes #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Vlczech
Copy link
Contributor

@Vlczech Vlczech commented Mar 26, 2017

If I use some classes on inputs, usage of:
{input some-input, class => 'some-class'}
leads to overwrite previously set classes.

However:
$form['some-input']->getControlPrototype()->addAttributes(['class' => 'some-class'])
leads to merge previously set classes with the other one classes.

@uestla
Copy link
Owner

uestla commented Mar 30, 2017

This doesn't work since it does the same thing as the native {input /} macro - see here.

->getPrototype()->addClass('form-control') however works...

@Vlczech
Copy link
Contributor Author

Vlczech commented Mar 30, 2017

That's strange... If i added some class to input and use yours {input forminput, class => 'form-control'}, class which i set was ignored. If I tried to use {$form['forminput']->getprototype()->addClass('form-control')} {$form['forminput']->getprototype()->addAttributes(['class' => 'form-control'])} immediately before your code (and delete , class => 'form-control' from this input), then the class was set in the final code. That's why I decided for this pull request.

When I have a moment, i will try once again.

@uestla
Copy link
Owner

uestla commented Mar 30, 2017

Yes that's correct, but in this pull request you're using addAttributes(), not addClass() :)

@Vlczech
Copy link
Contributor Author

Vlczech commented Mar 30, 2017

Sorry, that was a mistake, that i wrote another function thatn in pull request.

I used addAttributes as in pull request - editted previous message ;)

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.

2 participants