Angular Material forms validation error message won't go away - forms

I have a material form in which I have an MdInput:
<md-form-field class="input-full-width">
<input mdInput class="form-control" type="text" placeholder="Description" formControlName="periodDesc">
<md-error *ngIf="fb.get('periodDesc').errors.required">This field is required</md-error>
</md-form-field>
The validate message appears when the field has been touched but no text has been typed in. However, the validate message persists even when I try to type in text there:
Edit 1:
The issue gets fixed when I do this instead:
<md-error *ngIf="fb.hasError('required', ['periodDesc'])">This field is required</md-error>
However, my question is why did the issue occur in the first place? Is there anything wrong with the previous case because I am using it in other places where the second one won't work. Ref: Angular Material forms validation errors

The reason is that When a formControl has no validator errors(see here), fb.get('periodDesc').errors will return null. So your current way will throw null error like can not find required of null.
Use fb.get('periodDesc').hasError('required') instead of fb.get('periodDesc').errors.required to prevent from above error.

Related

How to add temporary field for "Reenter-Password" for TYPO3 Extensions?

in my FE-User-Registration Extension i want to add a 2nd Password-Field, just for checking the spelling of the first password entered.
I don't like to add an extra field for this in the database, because it's only for first entering the password and changing the password purpose.
If the normal password-field and the reenter-password-field are the same, it should be stored in the database. (I also make a salted password here, but it's not important for the issue.)
I tried the following
<label for="reenter_password" class="reenter_password">
Reenter Password*
</label><br>
<f:form.password id="reenter_password"/>
This makes no errors, but i don't get the value.
<label for="reenter_password" class="reenter_password">
Reenter Password*
</label><br>
<f:form.password property="reenter_password" id="reenter_password"/>
This makes the following Error:
Exception while property mapping at property path "": Property "reenter_password" was not found in target object of type "RM\Rmregistration\Domain\Model\User"
I know if i make an extra field called reenter_password in my Model, SQL, it would work, but like I said above I don't want to store this to the database.
Is there any way to get the value, and checks it, without storing it to the database with Fluid?
Try to put your input like this in your fluid template :
<input id="reenter_password" type="password" name="reenter_password">
And see what you've got in \TYPO3\CMS\Core\Utility\GeneralUtility::_POST() in your controller action.
I'd use an AbstractValueObject and validate this one, then, in your update action, take one of the values of the AbstractValueObject and set it in your entity.

SuiteCRM turn ON autocomplete on email recipient field

I'm trying to remove the autocomplete="off" attribute from the input field for the email recipient field
The code of the input field is as follows:
<input
class="ac_input yui-ac-input"
size="96"
id="addressTO1"
title="An"
name="addressTO1"
onkeyup="SE.composeLayout.showAddressDetails(this);"
autocomplete="off" type="text">
Is there a setting that can be accessed via the GUI that changes the behaviour of the email "to" field or what would be the best way to turn on the autocomplete functionality.
Just removing it does not work, as there is some javascript functionality there, that keeps bringing it back.
I'm using suiterCRM version 7.6.5
Sugar Version 6.5.23.
There is no GUI for changing that, the autocomplete=off is hardcoded.
The TO field (addressTO1 dynamically generated name) is not a regular text input field, it will support multiple emails separated by comma, so a autocomplete="email" will not work.
The only solution I could come up with is for you to create a javascript function and attach to the keyup event of the field and show your logic.
Also you will need to save previously filled input with the answers and provide a mechanism to delete that. Not an easy solution I am afraid.

Error Message for Error State in input

Is there a possibility to define own error messages for an input?
View
<Input id="inputReferenceId" change="handleChangeReferenceId" type="Text" />
I change the state this way:
Controller
handleChangeReferenceId: function(oEvent){
if(...)
this.byId("inputReferenceId").byId("inputReferenceId").setValueState(sap.ui.core.ValueState.Error);
//I need a own error message for the inputReferenceId input
}
}
I need a own error message like "Please fill in a valid Reference Number"
Is there a attribute like valueStateText or something?
It works. It was my fault. If the cursor leaves the field there is no valueStateText. onFocus the input field the text appears.
Here is a property:
valueStateText
Please check you SAPUi5 library version, as this valueStateText property is available from 1.26.0 onwards.

Getting a value from a label at POST

There's a place into my screen that I populate a label with a specific string value after some interaction with my user during the runtime. I use javascript for that.
Is there anyway to get the value of this lavel with my controller after its POST method is activated ?
Thanks, guys !
Option #1
Put the value in an HTML <input> element with a name attribute? Might need to dress down
the input element, since it will look like a textbox.
Option #2
Mirror the value in a hidden input <input type="hidden" value="yourValue" /> inside the form you're posting.

Tapestry 5 zone inside a form

I have a form and inside it I have a country/city/etc selection.
The form is inside a zone.
When calling the onSelected for make the change of the country/city, when returning I loose the other form data. How can I keep it ?
I think a zone inside the form would help, but I am getting:
Form components may not be placed inside other Form components.
The Ubigeos type is just a component with other selects that are filled from the pais select
My .tml is
<t:zone t:id="datosPersonalesZone">
<form t:type="form" t:id="formulariodatospersonales" t:zone="datosPersonalesZone">
<t:errors/>
Sexo: <select t:type="Select" t:id="sexo" t:value="actual.sexo" model="sexo" />
PaĆ­s: <input t:type="Select" t:id="pais" model="paises" t:value="pais" t:zone="ubigeosZone"/>
<t:zone t:id="ubigeosZone">
<input t:type="Ubigeos" t:id="ubigeo_nacimiento" t:ubigeo="ubigeoNacimiento" t:zone="ubigeosZone"/>
</t:zone>
</form>
Regards !
You either have to submit a form and process country selection differently (i.e. only updating form contents by returning a block) or try using ideas from FormFragment component and TriggerFragment mixin (probably you can't use them directly but you can try extending them to support select components).
Personally, I go with first option - I have a "SubmitFormOnEvent" mixin and attach it to select-s in the form. Then I found that similar approach is demonstrated at http://jumpstart.doublenegative.com.au/jumpstart/examples/javascript/ajaxselect1 -> so you just can start with that example and update it to your needs.