Is there a way in Angular2 to display all validations once the entire form is traversed? - forms

I am using Angular2 (2.2.1) for building my web app. I am facing a challenge here. I have multiple dynamic forms in my SPA and in all of them, I am keeping my Sumbit button disabled till all the mandatory fields are filled (I cannot change this behavior because of some restrictions).
My errors are displayed once the field is dirty (and of course if there are errors). However I would like to show that the user has missed some field completely once he has reached the end of the form. I thought of keeping the check on the last field of the form, ie. once it's touched, the validations for all the missing fields will be shown. However there is a major flaw in my logic here as it assumes no user will ever miss the last field which may not be the case.
So, is there any way this can be done in Angular2?

Related

Access 2010 Form: Including example input for fields?

I have an input form in which users submit multiple types of information to the database.
Is there any way I could provide an example input of what should go in each field, upon the form loading?
Some fields I'd expect a small paragraph of text, others are dropdowns. The dropdown fields I wouldn't need to put an example of course, just the string text fields. If I try and include an example in the Default value for example, it would save the default value, which I wouldn't want.
Any help is greatly appreciated - It's worth noting I'm quite new to Access & coding in general.
I agree you probably don't want to use default values, or actually enter dummy data into the actual controls for the reason you mention: saving dummy values to the table.
A few possibilities:
Use a custom tooltip. You can do this by editing a control's "controltip text" property. Keep in mind that tooltips are only visible to the user when they hover the cursor over the specific control.
Add a label below the input control that describes the information that should be put in the control. This would always be visible, but can quickly cause your form to be cluttered and difficult to read.
I should say though, that you want to attempt to make your forms as intuitive as possible. For example, if you expect a paragraph of text, make the textbox much larger than a control only expecting a 6 character string. The more you are concerned with UX (user experience), the greater the chance that users will pick up on expectations using subtle design hints. I highly recommend researching the topic if you are concerned that your users will be unable to decipher the purpose of your form/controls. Be sure to check out the UX page on SE.
Furthermore, you can utilize a control's "AfterUpdate" event to validate the input placed in the control as soon as the user moves away from it. For example, you could test if the input IsNumeric() to validate that numbers were entered instead of text. If text is found, you can use a message box to alert the user, and move the cursor back to the control that is invalid.
Of course, that's the customized approach to just using the control's validation rules. The only issue I have had with the standard validation rules is user exhaustion. It can be irritating for a user to deal with validation messages when they are already aware that a typo was made. With an unbound entry form that requires a save button, I usually batch all control validation into the save procedure. This allows the user free reign to skip controls in the tab order without being blocked by constant validation exceptions.

How to track checkboxes with Django and endless pagination?

I am a Django noob and have a situation that goes beyond the basic documentation, etc.
I am updating an ordering webpage that has a form structured as follows:
several text boxes, etc to gather general info (name, date, etc)
two separate tables for selecting (via checkbox) catalogs that are generated/managed using endless_pagination. Each table can have thousands of records, hence the endless_pagination. The first column in each table is a checkbox with value = catalog.id.
a textbox where the user can manually enter catalog IDs
a submit button
I am not sure how to keep track of what a user has selected in the two paginated tables since the checked boxes are lost when choosing a different page. Also, when the user flips back and forth between the pages, the previoulsy checked catalogs will need to be re-checked(since the checked state is not maintained). I am also not sure which tool(s) to use to deal with this.
My thought is to use JavaScript (with which I have minimal experience) to update a list of catalog IDs whenever a checkbox is checked/unchecked and:
- and attach that list to the form or
- update a variable in the form or
- send as a variable separate from the form, whichever is possible/makes more sense.
I'm hoping that maintaining a list of catalog IDs is possible because the next iteration of this form will likely include some sort of filtering so I'm trying to devise a solution that will not have to be reworked later.
I have reviewed a lot of posts but I believe the closest solutions are rendered useless because of the endless_pagination.
Let me know if further clarification is required. Thanks in advance for any suggestions.
UPDATE
I tried using JavaScript to store the catalog IDs in an array when a checkbox is checked. This does not work when a user selects another page in the pagination. The array of checked catalog IDs is lost when the page 'reloads'.
I'm running into this problem right now as well. I'm handling this by writing the checked items to localStorage so they carry across to page 2, 3, etc.. as well as show up as already checked when you go back to page 1. Then every time the page loads, either find and check the existing checkbox, or create a hidden input with the appropriate name and value and append it to the main form.
var selected_items = []
function add_item_to_checkbox(item) {
localStorage.setItem('selected_items', JSON.stringify(selected_items));
checkbox.on("click", add_item_to_checkbox);
bahh... Just look at my jsfiddle it's easier to read and yeah. I don't have to type JS into a textarea on stackoverflow.
Here is my javascript minus a few things that are specific to my code. I'm sure it could be improved upon but it works really well for my application.

How to enforce wicket to validate disabled fields on the page right before onsubmit call

if we use setEnabled(false) say on text input type it disables and not take part in form validation so how can i enoforce this right before onsubmit
As a general rule browsers do not submit the value of disabled fields at all. (As mandated by the HTML standard)
It's important to see that because of the browser sending no data, the problem is framework-neutral. The solution is also independent of your framework:
Double-fielding: each text field that you intend to disable should have a "shadow" hidden field where its value is copied.
In the Javascript function that does the submitting you can re-enable the fields for the time of submit only. I haven't tried this option yet so I'm not sure if this is a good idea or indeed if it works (it should though).
A separate, Wicket-specific issue is that even if the browser submits the values, any Wicket component which has setEnabled(false) called will refuse to process them. So you'll have to extend double-fielding into your Wicket component structure as well, which won't look very nice.
So it's doable but you should know that users will not expect disabled fields to be submitted and you're likely to cause confusion by changing the standard behaviour of form inputs. You might want to think about redesigning your UI as an alternative option.
If the component is disabled it won't have any input to be validated. I'll assume from now on that you want to execute a FormValidator which involves some other components' user input and this disabled TextField's model object.
Unless you return the disabled TextField in FormValidator.getDependentFormComponents(), the FormValidator will continue to execute. Take into account that FormComponent.getConvertedInput() won't return anything, because there's no input. You can get the Modelobject instead by using FormComponent.getValue().

ACCESS 2010 Navigation Form Query Property

I'm coming accross a problem and i have searched the entire World Wide Web:
I have a Navigation form which has forms in it.
Those forms are used to give properties to my queries.
For example:
FormStatus-->Ask user to select the status and shoot the value to the query.
These queries build reports.
The main problem is that now that my form is in a navigation form, the link for the property is no longer working.
The link used to be : Forms!myForm!myProperty
Now i tried
Forms!navigationForm!myForm!myProperty
Me!myForm!myProperty
Forms!ParentForm!SubForm.Form!FieldName
Nothing works out!! Can anybody help me?
As a general approach to filtering forms or reports, as you can see placing forms! references inside of forms becomes a rather messy business real fast here.
You are best to remove the forms! references from ALL your queries. You then build a form that the user enter the values into, and then execute a browseto command.
The problem you are experiencing here is that the new navigation form swaps out a given form for a new form. This means that the old form is NOT loaded anymore. So, either you
Plan A
Dump use of forms! commands in your SQL queries. This is a good idea anyway since then one query will not blow up because some silly form is not open. And more important the query can be used in other places in the application without fear of some form not being opened.
The instant you place a forms! reference inside of a query is the instant you ruin that query and force "marry" that query to one form that must be opened.
Plan b:
Dump the use of the new navigation control system. Just remember, the new navigation system does NOT load the next form, but "replaces" the one that is being displayed. Thus the previous form is not going to be loaded anymore and thus no forms! ref is allowed. Worse, since the navigation form is really using sub-forms, then the forms! references have to be changed.
You can certainly grab the values of controls and build a where clause in code and use that for openform or open report commands here.
Last but not least, if you in for lots of continued torture, you can stick with your poor design you have now and simply re-edit and fix all of the forms! references to reflect that they are now being used inside of a parent form, and all of your forms are now in effect being run as sub forms.
Try using a dot instead of ! before the property Forms!navigationForm!myForm.myProperty

Using multiple forms or multiple submit buttons, what's the difference?

Basically, what pros/cons are there to using multiple forms in the same web page vs one form with multiple submit buttons? Any difference at?
Ah? Multiple submit buttons on a single form will all submit the entire form when pressed... there's really no advantage to having multiples, unless you're overriding how the submit process works so each button only submits it's own area. In this case they'd probably not even by submit buttons, but just buttons with sum JS code to handle submission.
Multiple forms are discrete spaces of data collection, each can have it's own submit button... but only one of them can be sent at a time (and depending on the browser you may loose what's in the other forms).
Neither approach is particularly good from a user interface perspective since it'll be confusing.
The real question is, what are you trying to do that prompts you to ask this?
The two behave differently and there are good reasons to choose one over the other.
Multiple Forms on a page allow you to send data to two different locations. A common example is to have an input form as the main focus of a page going to one location, and a search form that appears as part of the generic header/footer. These both go to separate locations and submit only the HTML form elements within their appropriate <form/>
Multiple submit buttons offer you the ability to give different purpose to a submitted set of form elements. E.g. One form may have a bunch of submit buttons all with name attributes, meaning you can add conditional logic on the server side to say: "Continue", go " Back" or even "Save for later". All reference only the form elements within it's parent tag.
Two side notes are: 1) You can't nest forms. 2) JavaScript can change this default behaviour if you wanted it to. :)
Edit: with reference to a comment you made, if you wanted to do without JavaScript (a wise choice while it's not needed), you could do some careful thinking and keep POSTing the form to itself. Each time checking which form button has been clicked (top tip, give them all the same name and you can just switch case through it) and do whatever you need to do, including performing validation. E.g: When they hit "add media", you'd save the media uploaded and return a reference of it to the screen as a hidden input. The user can then continue to add things to the other boxes and when complete, hit your save button, at which point you do all the main saving work and make sure you tie the uploaded file to it as well.
You effectively keep adding stuff to their screen until they hit the save and then you perform a save method and redirect to a thank you page (or whatever logic suits your scenario). :)
All fields in a form are sent when one of their submit button is clicked. It's for you to see if you need all fields or not.