Skip to content
This repository has been archived by the owner on Nov 24, 2018. It is now read-only.

Explicit Control of valdr-messages location #78

Closed
br0dieman9 opened this issue May 18, 2015 · 7 comments
Closed

Explicit Control of valdr-messages location #78

br0dieman9 opened this issue May 18, 2015 · 7 comments

Comments

@br0dieman9
Copy link

Would it be possible to modify valdr so that someone can place a new element (maybe a valdr-message-placeholder) on a form, so that form field messages (Ideally one placeholder per field, or a single placeholder that acts as a validation summary) are appended to that element instead the default location (the parent outside of a valdr-form-group or the valdr-form-group element). I have been trying to get the messages to show up using a bootstrap horizontal form, and the messages are showing up to the bottom and left of each field because they are not rendered in the bootstrap columns.

<div class="row" valdr-form-group>
    <label for="Quantity1" class="control-label col-xs-2">Gemstone Quantity</label>
    <div class="col-xs-10">                                    
        <input type="text" ng-model="vm.maintenance.Quantity1" class="form-control" id="Quantity1" name="Quantity1" placeholder="Gemstone Quantity">
    </div>
    <!-- MESSAGES END UP HERE-->
</div>

The code above works, but the message is appended outside the two columns. If I move the label outside the form group, it does not change color with the field but with the form instead.

I would like a feature that would allow for valdr-message-placeholder to be specified.

<div class="row" valdr-form-group>
    <label for="Quantity1" class="control-label col-xs-2">Gemstone Quantity</label>
    <div class="col-xs-10">                                    
        <input type="text" ng-model="vm.maintenance.Quantity1" class="form-control" id="Quantity1" name="Quantity1" placeholder="Gemstone Quantity">
        <div valdr-message-placeholder valdr-message="Quantity1"></div>
    </div>
</div>

Is this possible?

@marcelstoer
Copy link
Collaborator

Do you have a working example/demo somewhere (e.g. Plunker)? We need to look into this because the validation messages are supposed to show up next to the input element. Can you compare your implementation against the demo once more.

@br0dieman9
Copy link
Author

Here is a working demo of the different things I've tried:
http://plnkr.co/edit/HBnX6hyNmeQY4iqyHznQ?p=preview

Try entering the letter a in each field.

@mmatczak
Copy link

This worked in my case:

<div class="row">
    <label for="Quantity1" class="control-label col-xs-2">Gemstone Quantity</label>
    <div class="col-xs-10" valdr-form-group>                                    
        <input type="text" ng-model="vm.maintenance.Quantity1" class="form-control" id="Quantity1" name="Quantity1" placeholder="Gemstone Quantity">
        <!-- MESSAGES WILL END UP HERE-->
    </div>
</div>

The only thing is that the class form-grouphas also been added to the div which broke the Bootstrap layout, but you can change the class' name as described here

As I am very new to valdr, I can't judge if this is a right way...

@mmatczak
Copy link

Now plnkr is up again and I see you have already come up with this idea...

@philippd
Copy link
Collaborator

This is already added as a feature request in #17

@br0dieman9
Copy link
Author

Has the feature been implemented? Any idea where I can take a look for an example?

@marcelstoer
Copy link
Collaborator

No, check the comment just above yours.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants