AngularJS: Form validation whereas html is not displayed - angularjs

I'm developing an application containing several forms, each included in a specific route.
I need to validate all those forms on a global button click. But one form is displayed only, the others don't exist.
How can I process this validation whereas the HTML containing the validation rules (ng-required, ...) is not instantiated?
Thanks.
Vincent.

Related

angular: creating a simple input dialog box from a form action

Note: I am not well versed with angularjs/frontend dev as such, so I may be using wrong words/terms.
I have a form as a result of a html and a controller. Controller has functions defined which are invoked when user performs some actions as defined in html, like clicking a button.
One of the UI element in the form is ui-select. It enables user to select multiple values from a dropdown.
What I want is that when user clicks on one of the selected value from ui-select, a new dialog window opens up wherein user can provide some input value, close it, return to original open form, and value from dialog box gets appended to the original clicked value from ui-select.
I want to know what is best way of creating an input dialog box in angular.
I see $uibModal being used which can be used to create a form by combining a html and a controller. But I have a usecase for a simple dialog box. So it seems $uibModal is bit of an overkill.
Is there an easier way of doing this?

Dynamic Form Validations in Angular Js

I am Struggle With Dynamic Form Validation In My Current Project, in my Form Having Two Fields like User Name and Email, Both Are Mandatory.
If User Click Add-More(Up to 2 times only) Button Then Same above fields are came. those two fields are also Mandatory. if user removes those fields validation will not be work
I Already Wrote those 2 fields(3 times) just, I Kept ng-hide and ng-show,
And My Code is below,
enter code here
I have Added My Code To Plunker:
http://plnkr.co/edit/ErJl2Kg8maOn5GLaz9mb?p=preview
Avoid to use ng-hide or ng-show.
Prepare on model i.e. JSON Array and bind using ng-repeat and write associated code in JavaScript.
Example: Click here for Example
Use ng-required="showUser2" instead of just required.
In an AngularJS-form a field is still required even when its hidden.
That means when you hide your required form input field with ng-hide or ng-show then the AngularJS FormController completeProfile still treats the form as $invalid.
To get dynamic forms how you want them you can use ng-if to hide your unwanted input fields. Input fields inside of a ng-if are not considered by the form validation logic.
I updated your Plunker. The submit button is only shown when the form is valid.

Sitecore MVC Checkbox

In Sitecore MVC, FieldRenderer.Render(Item, "Field Name") automatically checks its field type. In another word, all XSLT extensions (sc:text, sc:image, sc:date, …) is affected by the RenderField pipeline.
But, I couldn't find sc:checkbox information and it doesn't show "CheckBox" in page edit mode. It just shows the value of the check box.
How can I make it show as like input type=checkbox in page editor?
Sorry for the link only answer but the general approach here is to use a Field Editor Button.
This will open a pop up window with the content editor style control for the field.
If using a custom experience button is not an option for you, you can output different markup (i.e. your input button) to the client when the page mode is in 'Edit' mode.
This will allow you to present the author with the controls you wish to display, but still output the normal output values for end users.
If you are able to use controller renderings, you can use the controller to load a different view to make this easier, but otherwise you can use if statements within your View to output different markup.

Check form is modified for certain inputs

I have a form with some tabs.Each tabs has set of some controls which are binded using angularjs and has ng-model .I want to check whether user has entered or modified any data in a particular tab during submit.
myForm.$dirty will check whether user has interacted with the form. But I need to check controls are filled in particular tabs and give some appropriate messages . So can i check angularjs watch or ng-dirty for each controls and verify that user has modified data. Is there any other good solution for the same?
In angularjs you can make very different validations when using forms and classes like ng-dirty and ng-touched.
This way u can check wether determined control has been modified.
ng-dirty: the control has been interacted with
ng-touched: the control has been blurred
Also you can check validity or other similar things.
U have all the docs at:
https://docs.angularjs.org/guide/forms
Anyway, you can also check this with the FormController
https://docs.angularjs.org/api/ng/type/form.FormController
And then show the messages with angular directives for bootstrap (see Modals)
https://angular-ui.github.io/bootstrap/
As you say, you have different controls and you need to show different messages depending on the control and on the user´s input. Then I think the way you musts code it, is by looking for ng-dirty or ng-touched
There you have an example about how using it:
http://www.w3schools.com/angular/angular_validation.asp
Hope it can help!!

Create a template using another template

I'm trying to create a template which renders a form and then cache that form as template so that I can use it in displaying form with user inputs while in edit.
So far I tried merging both the data (form configuration data+ form input given by user) and render the form. But this won't allow me to cache the form as template and need additional work to retrieve the user input while saving.
Thanks.

Resources