Disabling Input Field when value is pre-populated - angularjs

An edit, and add user form group utilizes the same view. However on edit, the username, password, and other details are autofilled into the form instead of presenting a blank form. The form (specifically for username) needs to be disabled, if and only if the field was pre-populated.
Using ng-readonly or ng-disabled works when the user is editing the form (username is disabled if username.length is true).
ng-readonly="username.length"
However, when the user is creating a new profile, typing in one letter into the username field will disable it, as ng-readonly recognizes that the username field has a length of 1. How would I set it so that Angular only checks to make the field read-only once instead of constantly monitoring changes in the field. The other problem is that I don't want Angular to completely ignore the field's changes, as validation (such as min length and isrequired) still need to fire.

Presumably you have a way of knowing whether or not the form is in 'add' or 'edit' mode. Can you just replace the condition of ng-readonly with an "isAdding" boolean?

Related

MUI DataGrid: How to read unsaved input valueS?

I'm using MUI's datagrid in edit mode, following the CRUD component example. When adding a new row, the save button should be disabled until all fields are populated. As seen below, I'm able to save even when the name field is empty. This should not be the case.
In order to validate, I need to read unsaved values entered by the user, i.e. age 10. The actions column is rendered using the getActions field. I logged the getActions parameters but it gives empty values. I entered 'strategic' below but the name field is "".

$dirty in angularjs remains true after removing the changes

I am using $dirty to check the changes in a form ,but if i type something in the input box and remove it, the $dirty is still true.Is there any solution or it will work like this.
That is by design. Any form becomes $dirty whenever the user interacts with it, and you cannot undo the interaction event. Though you can restore defaults, that is clearly not the same.
Consider using $watch to check whether new value is different from the default one, and $setPristine() to clear user input.
$dirty means The field has been modified one more time. for compare your model by your previous model you can use $watch in controller.
if your field is empty you have a solution must set required attribute and in your input tag and use below code set ng-validate of your form to novalidate and then use below code for compare:
formName.inputName.$dirty && formName.inputName.$error.required
$Dirty refers to the form field is modified and you want to check using $pristine

how to set focus to an input element when page gets scroll in ios?

I am working on a project based on angular and ionic. I have a page consisting of sign up form. It has four fields namely email,mobile no, password and confirm password.The issue I am facing is that when I tap on confirm password field then keypad gets open and page gets scrolled. then confirm password field loses its focus. cursor is not get set to that field as well as whatever I typed on keyboard is not get shown in field unless I click outside.

Opening Button to open form based on combo box selection

I currently have a MS Access database of members.
I have a form that has a combo box which is populated with just the first and last names of members. (using a test database for now)
What im struggling with is how do i create a button that opens another form i have created but using the selection in the dropdown box to populate the fields in the newly opened form.
When a user from the dropdown box is selected an open is clicked i want it to open the profile form populated with their details.
pictures and access files can be found on my ftp server:
ftp://ftp.legends-gym.co.uk
User: ftpuser#legends-gym.co.uk
Pass: ftpuser
Regards
I can't access ftp site from work so can't see what you've got thus far however, the key bits you want to look at here are:
Add a button to the form and the On Click Event to open your profile form. Something along the lines of docmd.openform "frmProfile", acNormal
You need something to pass the member you've selected in the combo box to the profile form. One way might be to use OpenArgs so have a look at that
You then could use the passed variable in OpenArgs to select the data you want to fill out your profile form.
EDIT...
OK, I've had a look at the file now. Here is what you need to do to fix your problems (and a couple of extra bits which aren't causing an issue but will improve the look and feel).
On the Format of the Home form and the Member Search form, set Navigation Buttons and Record Selector to false. - This removes the unnecessary elements for a "single" form, you're not looking at records.
On the member search form, remove the binding to the members table. - You don't need to bind this form, as the recordsource of the combo is pulling the data required separately. if you look at your form before you change it, you'll notice you've got 1 of 10 records...
Also, remove the filter criteria and set filter on load to No - You were filtering the wrong form.
On the combo box, remove the after update event. - I'm not sure what that was trying to do but its completely unnecessary.
On the command button, add an onclick event which has the following code DoCmd.OpenForm "Profile", acNormal, , "ID = " & Me.Combo361 & ""
Save everything and enjoy. :)
You weren't far wrong with the filter, but it's actually a WHERE clause when opening another form - sorry, my bad misdirection. What you were doing was filtering the original form - ie the member search form. Also, you don't need to put ' quotes around the ID, it's a number not a string.
If you have problems I can probably host this fixed version somewhere for you to download.

Angular Formly - HideExpression on page load

I have a number of fields on my form. When the user changes the selected value in a dropdown, there is a hideExpression on each field that shows/hides the fields depending on what the user has selected. This currently works fine.
However, I am trying to make the dropdown default to the first option in the select. This also works fine.
My issue is that all of the hideExpression logic is not being fired upon loading of the screen. So the select is defaulting correctly but none of the fields (that should be shown) that go with that option are visible.
If I manually change the dropdown value then everything is shown correctly. Is there a way to make the hideExpression logic get kicked off even when the select is being defaulted via code?
Here is a JSBin for my issue: http://jsbin.com/doliyiruza/edit?js,console,output
The page defaults to Option2. Yet, there is a hidden field that should show whenever Option2 is selected. So if you change the dropdown to Option1 and then back to Option2...you will see the hidden field. The hide/show logic doesn't seem to get kicked off if you set a dropdown to a certain value by default.
I'm not 100% sure why what you had wasn't working, but querying the DOM in your controller is a very very bad idea. Also, angular-formly intentionally tries to make field IDs non-deterministic so you can't do that (should probably make it more random). Here's what I think you're trying to accomplish: http://jsbin.com/bifaza/edit?js,console,output

Resources