UI-Select default placeholder than can change - html

So I would like to set my placeholder to have a default value which I originally had, but I have a modal view which when I create a user it updates which is done due to the following code:
<ui-select-match class="ui-select-match" placeholder="Test">{{$select.selected.loginName}} </ui-select-match>
However I would like to have a value beforehand, such as please select an option, etc. I tried using:
attrs.$set('placeholder', userEntity.loginName)
But atlas, no success. I was wondering has anyone had this issue before and if so, is it possible to have a default placeholder which can then be changed?

You should use ng-attr-placeholder to bind the attribute value to an angularJS expression, validate if the value you want to use is there otherwise return a fallback string {{ placeHolderMsg ? placeHolderMsg : 'Default placeholder'}}
e.g.
<ui-select-match
class="ui-select-match"
ng-attr-placeholder="{{ $ctrl.userEntity.loginName ?
userEntity.loginName : 'Please select an option'}}">
{{$select.selected.loginName}}
</ui-select-match>

Related

How can my text input be empty if the value attribute is set?

Have a look at the following screenshot. You can see that the text input field is empty, yet its value attribute is set to "b".
You'll also notice in the Properties tab, under input, that value here is set to "". Why are they different? What does this mean?
Could this be related to the fact that the input was rendered by React?
If it helps, here is the jsx responsible for this element (redacted):
return (
<td
key={field._id}
className={`oldField ${colPos}`}
>
<input
type="text"
defaultValue={value}
onChange={this.changeOldField(record, field)}
/>
</td>
)
It seems that you are changing the defaultValue based on something from the state. The defaultValue prop should be set only once and not changed later on, because any more changes will be ignored by React. If you want to change the value based on state you should use the normal value prop. Otherwise, if you want a predefined value to appear to the user and at the same time control the input when it gets changed, you can either use some logic in your code that handles both onChange and the code in your component that wants to automatically change the value, or possibly place it in the placeholder prop, which will give you something like what you want.

can we change the font color of a field based upon the value of another field?

I know we can change the font color of a field based upon the value of the same field as follows..
=IIF(Fields!Field-name.Value<100,"red","green")
writing this expression in the font property of particular field.
But how can we change the font color of one field basing on another field's values? Is it possible to change in this way?
Yes, you can reference any fields in the expression; it will use the value(s) in the current scope.
With some simple data:
And a simple table:
I have set the FieldValue2 textbox to have its Color based on an expression using the FieldValue1 value:
=IIf(Fields!FieldValue1.Value < 100, "Red", "Green")
Which works as expected:
You cannot use CSS, because CSS does not allow variables.
May I suggest instead using SASS, which does support variables, and using javascript to change said variables.
See a guide for SASS here

using checkboxes in Laravel's Form::model

I'm having trouble with Laravel's Form::model() construct. I was able to populate it with my model data but the checkboxes aren't being checked. The values are being set to 1 or 0 (courtesy of Eloquent calling a "boolean" a "tinyint" in MySQL), but I can't see how to use the Form::model() approach and set that checked attribute if the value coming is an integer and not a boolean (hence why I think Form Model Binding for checkboxes isn't working).
I'm specifying this in my view:
{{ Form::checkbox('hasDiscount') }}
And the form builder is returning this:
<input name="hasDiscount" type="checkbox" value="1" id="hasDiscount">
I think it's not really related to data-value. The value could be 'true' and the checked attribute could be false as well.
If you want to display checkbox with checked attribute, you can try my wait (it's not the best, I admit):
Form::model($model)
Form::checkbox('name', null, $model->value)
Form::close()
The third parameter could be convert to false if the value of model is null or 0 and the checkbox is not checked. otherwise, it's checked.
If you have another idea, please share it.

Putting HTML in a hidden form field in Django

I'm having a problem with a template: I'm trying to display a form for changing a value, in which the user enters the current value in a textarea and the old value is kept inside a hidden field for auditing purposes. This value is generally some HTML, and when I render the page this HTML in the hidden field seems to get partially rendered: the value attribute of my hidden field gets closed by the first quotation marks inside the entered HTML, and the rest of the HTML spews out onto my page. I've tried using the escape decorator but that hasn't changed anything.
Firstly, a better solution might be to keep the audit value in a separate model field defined with editable=False. You can still perform checks against the value in a form's clean method:
def clean(self):
cleaned_data = super(SomeForm, self).clean()
if instance.the_audit_field == cleaned_data['the_editable_field']:
...raise a validation error?
You can also modify the value of the audit field from within the model's save method.
Secondly, assuming you must do it the way you are now, let me address the non-escaped value in your template. I assume you're using something like the following:
<textarea value="{{ form.the_audit_field.value }}"></textarea>
You should instead use the following:
<textarea>{{ form.the_audit_field.value }}</textarea>
Note, the value goes inside the textarea, instead of in the value attribute of it.
An even better way to do it is to simply allow Django to render the field for you like the following:
{{ form.the_audit_field }}

Can't remove the value entered in the djFilteringSelect dojo control in xPages

I am using the djFilteringSelect control to show values in a dropdown as user type a value.
The lookup and typehead is working fine. The user type a letter and the dropdown allow the user to select a value which is then displayed in the dropdown field.
If the user now decide to remove the value first selected so that the combobox is empty and leave the field, then the first value in the list is now automatically filled in.
The consequence of this is that if the user have added a value there is no way to remove the value and leave the box emtpy.
I am using required=false for both the control and the dojo attribute but it does not seem to help. There are also a few other djFilteringSelect attributes I have tried like "Autocomplete" and "trim" but it does not work
Here is the code
<xe:djFilteringSelect id="test" type="select" store="jsondata" searchAttr="data" required="false" labelType="html" invalidMessage="Not valid">
<xe:this.dojoAttributes>
<xp:dojoAttribute name="required" value="false"></xp:dojoAttribute>
</xe:this.dojoAttributes>
</xe:djFilteringSelect>
Initally the field is not required, but if the user have entered a value it is required.
My question is if there a way to prevent the djFilteringSelect control to always populate the field if I have previously added a value
I found someone who solved this in another stack overflow topic, by creating an empty entry in my data store. but I could not get this to work
Dojo: Select of empty value for FilteringSelect while required=false
I do this quite a lot. Right now I don't have a working sample to show you (since I moved to bootstrap - and have to code the selects by manually adding select2 controls) but something like this should do it...
I add an "empty" value at the top of my select - and that seems to work no matter whether I am using a combobox, djCombobox or combobox with select2 from bootstrap. My markup typically looks like:
<xp:comboBox id="inputLocationSelector" value="#{User.catchListType}" disableClientSideValidation="true">
<xp:selectItem itemLabel="(none)" itemValue=""></xp:selectItem>
<xp:selectItems>
<xp:this.value><![CDATA[${Configuration.meta.listLocationTypeOptions}]]></xp:this.value>
</xp:selectItems>
</xp:comboBox>
Then you could specify "(none)", "All" or " " for the "not-selected" value depending on your needs.
Validation is a different thing so just specifying "required=false" does not give you the "empty" value.
/John