This works, I have all my items showing up in my drop down list, but there is also a blank entry I want to make sure that if the user selects this, the form will be invalid.
I had a look at how it works in Umbraco, but its not Obvious or maybe I am looking in the wrong place.
so this is the code for the built in dropdown.html in umbraco.
<div ng-controller="Umbraco.PropertyEditors.DropdownController" ng-switch="model.config.multiple">
<select name="dropDownList"
class="umb-editor umb-dropdown"
ng-switch-default
ng-model="model.value"
ng-options="item.id as item.value for item in model.config.items">
<option></option>
</select>
<!--NOTE: This ng-switch is required because ng-multiple doesn't actually support dynamic bindings with multi-select lists -->
<select name="dropDownList"
class="umb-editor umb-dropdown"
ng-switch-when="1"
multiple
ng-model="model.value"
ng-options="item.id as item.value for item in model.config.items">
</select>
</div>
I can not see any refrence to the validation object. - But if I look at DataPicker for example...
<div class="umb-editor umb-datepicker" ng-controller="Umbraco.PropertyEditors.DatepickerController">
<ng-form name="datePickerForm">
<div class="input-append date datepicker" style="position: relative;" id="datepicker{{model.alias}}">
<input name="datepicker" data-format="{{model.config.format}}" id="{{model.alias}}" type="text"
ng-model="datetimePickerValue"
ng-required="model.validation.mandatory"
val-server="value"
class="datepickerinput" />
<span class="add-on">
<i class="icon-calendar"></i>
</span>
</div>
<span class="help-inline" val-msg-for="datepicker" val-toggle-msg="required"><localize key="general_required">Required</localize></span>
<span class="help-inline" val-msg-for="datepicker" val-toggle-msg="valServer">{{datePickerForm.datepicker.errorMsg}}</span>
<span class="help-inline" val-msg-for="datepicker" val-toggle-msg="pickerError"><localize key="validation_invalidDate">Invalid date</localize></span>
<p ng-if="model.config.offsetTime === '1' && serverTimeNeedsOffsetting && model.value" class="muted">
<small><localize key="content_scheduledPublishServerTime">This translates to the following time on the server:</localize> {{serverTime}}</small><br/>
<small><localize key="content_scheduledPublishDocumentation">What does this mean?</localize></small>
</p>
<p ng-show="hasDatetimePickerValue === true || datePickerForm.datepicker.$error.pickerError === true">
<a href ng-click="clearDate()"><i class="icon-delete"></i><small><localize key="content_removeDate">Clear date</localize></small></a>
</p>
</ng-form>
</div>
You can see how it uses the validation object to make sure the feild is not blank. - So I would really like to know how umbraco does this.....
That is setting up the same control via the UI and ticking mandotory. I just want to copy the exact same thing
I could potentially do that, but that would involove me manually applying the CSS validation class to the drop down list too.
So far I have been able to get all these controls to work exactly the same way do do in "Umbraco" (the content tree) I set the corret validation config and pow... everything works with out the need to do anything manually.
When you create a drop down "normally" using doctypes, you can select mandatory check box and then if the user selects the blank record in the content tree the validation kicks in....
I might have to do it manually, but there must be away to do it the way umbraco does I'm just not sure where to look other than the property editors HTML (dropdownlist.html) - but it looks like this is happening outside the control..........
I think that's what I am trying get at. I want to see what is trying to do that validation maybe there is a bug when you apply a custom control .. it migt be worth doing an our umbraco trawl and or looking at the issues to see if this is a known thing.
Validation - Custom Section/Drop Down List
Hi,
I'm creating a custom section in the Umbraco Back office, in one of my views I have a drop down list.
In my HTML view I rendering the drop down list like this:
and vm.campaign.campaignTypePropertyEditor
Is created like this:
This works, I have all my items showing up in my drop down list, but there is also a blank entry I want to make sure that if the user selects this, the form will be invalid.
This works for text boxes:
What do I need to do to get this to work for drop downs?
No Replies...... :-( Do I need more information in this question?
This is starting to drive me crazy.........
How the hell does umbraco do it? all I want to do is stop the user selecting the blank option in a drop down list.
I'm reusing the dropdownlist property editor from umbraco. For all the other property editors this works, but not for a drop downlist.
Looking at the built in umbraco dropdown.html there is no refrence to validation....
SO how the hell does this work? ahhhhhhhh
Umbraco I love you but sometimes........
Only just walked to this, but have you found a drop down that does what you want and pick that apart..
Obviously on the controller you can do normal validation as a back stop ie check if the value blank and the return it as an error...
I had a look at how it works in Umbraco, but its not Obvious or maybe I am looking in the wrong place.
so this is the code for the built in dropdown.html in umbraco.
I can not see any refrence to the validation object. - But if I look at DataPicker for example...
You can see how it uses the validation object to make sure the feild is not blank. - So I would really like to know how umbraco does this.....
That is setting up the same control via the UI and ticking mandotory. I just want to copy the exact same thing
also what value is getting sent through to the controller if it is not blank.. it might be a whitespace and that maybe the issue
This is the HTML, I am not adding the first one Value="" umbraco is doing that.... I want to stop them selecting the first blank option
so is the "empty" value coming through to the controller and what is it, and if you can see what it is then you can capture it, and error it..
I could potentially do that, but that would involove me manually applying the CSS validation class to the drop down list too.
So far I have been able to get all these controls to work exactly the same way do do in "Umbraco" (the content tree) I set the corret validation config and pow... everything works with out the need to do anything manually.
When you create a drop down "normally" using doctypes, you can select mandatory check box and then if the user selects the blank record in the content tree the validation kicks in....
I might have to do it manually, but there must be away to do it the way umbraco does I'm just not sure where to look other than the property editors HTML (dropdownlist.html) - but it looks like this is happening outside the control..........
Do you get what I mean?
I think that's what I am trying get at. I want to see what is trying to do that validation maybe there is a bug when you apply a custom control .. it migt be worth doing an our umbraco trawl and or looking at the issues to see if this is a known thing.
is working on a reply...