Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Merge requests
  • !29228

[v4] Improve form control validation

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/browner12/patch-2 into master Aug 08, 2019
  • Overview 0
  • Commits 2
  • Pipelines 0
  • Changes 1

Created by: browner12

Problem

Currently server side validation requires an .invalid-feedback element to be a sibling of a .form-control element. This works fine most of the time. However, sometimes we have elements to don't fit into standard form control inputs. For example, I have multi-column checkbox area that allows for overflow scroll in the y direction.

<div class="col-12 col-sm-10">
    <div class="form-control is-invalid rounded p-2">
        <div class="row" style="height: 200px; overflow-y: scroll; ">
            @foreach($domains as $domain)
                <div class="col-12 col-md-6 col-lg-4">
                    <div class="form-check form-check-inline">
                        <input name="domains[]" type="checkbox" id="domains.{{ $domain->id }}" class="form-check-input" value="{{ $domain->id }}" />
                        <label class="form-check-label" for="domains.{{ $domain->id }}">{{ $domain->domain }}</label>
                    </div>
                </div>
            @endforeach
        </div>
    </div>
    <div class="invalid-feedback">Something went wrong.</div>
</div>

However, wrapping this element in a .form-control causes a lot of unwanted styling, that can often break the layout of it.

Proposed Solution

This change allows us to apply any class that starts with .form-control to the element, and still trigger showing .valid-feedback and .invalid-feedback elements. Now we can wrap any non-standard form controls in the class of our choosing, and still get validation.

<div class="form-control-no-styling is-invalid rounded p-2"></div>
<div class="invalid-feedback">Something went wrong.</div>
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/browner12/patch-2