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

activeControlGroup without has-error class support #310

Open
fedek6 opened this issue Aug 20, 2015 · 5 comments
Open

activeControlGroup without has-error class support #310

fedek6 opened this issue Aug 20, 2015 · 5 comments

Comments

@fedek6
Copy link

fedek6 commented Aug 20, 2015

Hi,
When there is error in a field activeControlGroup does not add has-error CSS class to it's container or print error message below.

echo TbHtml::activeControlGroup(TbHtml::INPUT_TYPE_TEXT, $model, 'username' );

Maybe I'm doing something wrong?

Variable $errorCss is not used anywhere across TbHtml class.

@fedek6
Copy link
Author

fedek6 commented Aug 20, 2015

This fix works for me:

if( !empty( $model->getErrors( $attribute ) ) ) { self::addCssClass( self::$errorCss, $groupOptions); }

At the end of activeControlGroup method of the TbHtml class.

@marcovtwout
Copy link
Collaborator

What happens when you just use TbHtml::activeTextField()? I'm not sure if activeControlGroup() is meant to be called directly.

@fedek6
Copy link
Author

fedek6 commented Aug 24, 2015

It adds class error to the input field but it's not compatible with bootstrap. It should look like this: `


Input with error

` instead of ``. Maybe I should render form using some other method?

@marcovtwout
Copy link
Collaborator

It works as expected when using a TbForm or TbActiveForm.

Your view code for example calls $form->textFieldControlGroup(). This calls processControlGroupOptions() first (and sets the error class) before calling TbHtml::activeControlGroup().

As these are valid workarounds, it still looks like you found an inconsistency in the API.

@crisu83
Copy link
Owner

crisu83 commented Oct 30, 2015

@fedek6 maybe you can create a PR to fix this issue so that we can merge it into the project?

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

No branches or pull requests

3 participants