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

A flexible possibility for InputErrorClasses (Ready for Bootstrap 4+) #71

Open
mano87 opened this issue Jul 30, 2020 · 5 comments
Open

Comments

@mano87
Copy link

mano87 commented Jul 30, 2020

Hello,
currently it is only possible with great effort to use the forms in combination with Bootstrap 4+. It would be good if you could use the InputErrorClass independently from the helper formRow.

Or is there a better way to implement the attached example? See the following code snippets...

/** @var Laminas\Form\View\Helper\FormElementErrors $helper */
$helper = $this->formElementErrors();
$helper->setMessageOpenFormat('<small class="invalid-feedback">');
$helper->setMessageCloseString('</small>');
$helper->setMessageSeparatorString('');
<div class="form-group row">
    <?php echo $this->formLabel($matriculationnumber); ?>
    <div class="col-sm-10">

        <?php if ($matriculationnumber->getMessages()) {
            $classAttributes = $matriculationnumber->hasAttribute('class') ? $matriculationnumber->getAttribute('class') . ' ' : '';
            $classAttributes = $classAttributes . 'is-invalid';
            $matriculationnumber->setAttribute('class', $classAttributes);
        } ?>

        <?php echo $this->formElement($matriculationnumber); ?>
        <?php echo $this->formElementErrors()->render($matriculationnumber); ?>
    </div>
</div>
@froschdesign
Copy link
Member

Related to #62 and #63

@froschdesign froschdesign changed the title A flexible possibility for InputErrorClasses (Ready für Bootstrap 4+) A flexible possibility for InputErrorClasses (Ready for Bootstrap 4+) Jul 30, 2020
@driehle
Copy link
Contributor

driehle commented May 26, 2021

@mano87 Until laminas-form supports this, I can recommend you @neilime's twbs-helper-module, which extends the helpers, changes the HTML accordingly and overrides the service manager's config to transparently use the extended helpers. That way, you will have all markup rendered according to Boostrap 4+.

@froschdesign
Copy link
Member

…Boostrap 4+.

At the moment, version 5 is not yet supported: neilime/twbs-helper-module#165
But there is already a first pull request: neilime/twbs-helper-module#167

@froschdesign
Copy link
Member

@mano87

/** @var Laminas\Form\View\Helper\FormElementErrors $helper */
$helper = $this->formElementErrors();
$helper->setMessageOpenFormat('<small class="invalid-feedback">');
$helper->setMessageCloseString('</small>');
$helper->setMessageSeparatorString('');

You can use a factory for this. An example can be found in the forum.

@neilime
Copy link
Contributor

neilime commented May 28, 2021

…Boostrap 4+.

At the moment, version 5 is not yet supported: neilime/twbs-helper-module#165

But there is already a first pull request: neilime/twbs-helper-module#167

We are working on it, contributions are welcomed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants