Skip to content

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

@mano87

Description

@mano87

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>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions