logo
down
shadow

check if a form field has changed using a play Form object


check if a form field has changed using a play Form object

By : user2953409
Date : November 20 2020, 01:01 AM
will help you In shortest words Form isn't able to check if fields are changed it's just stateless between request and to check it you just need to get record from DB and compare field, by field.
Also you shouldn't rely on client-side validation as it's mainly for cosmetic, NOT for safety. Remember that it can be manipulated or omitted quite easy with common webdev tools.
code :
public static Result save() {
    Form<Device> boundForm = deviceForm.bindFromRequest();
    if (boundForm.hasErrors()){
        return badRequest(devices.details.render(boundForm));
    }

    Device boundDevice = boundForm.get();
    Device existingDevice = Device.find.byId(boundDevice.id);

    if (boundDevice.name.equals(existingDevice.name)){
        boundForm.reject("Contents are identical");
        return badRequest(devices.details.render(boundForm));
    }

    // else... form hasn't errors, name changed - should be updated...
    boundDevice.update(boundDevice.id);
}  
@if(yourForm.error("identicalContent")!=null) {
    <div class="alert alert-danger">@yourForm.error("identicalContent").message</div>
}


Share : facebook icon twitter icon
how to check that any form field data is changed or not?

how to check that any form field data is changed or not?


By : Ievgen Barakhtian
Date : March 29 2020, 07:55 AM
hope this fix your issue JavaScript may help you, but it's very unreliable. I say go with the second option. Store the ICustomer object in a Session variable and compare it with the new one.
Object as Field Form in Play Framework 2

Object as Field Form in Play Framework 2


By : Dashaun Slaughter
Date : March 29 2020, 07:55 AM
wish helps you Try to put javax.validation.Valid annotation on your object field. Like:
code :
public class Vehiculo extends Nodo {

    @Required(message = "Este campo es requerido")
    private Integer capacidad;

    @Required(message = "Este campo es requerido")
    private boolean disponible;

    private String modelo;

    @Valid
    @OneToOne
    private Propietario propietario;

    ...
}
In AngularJS, how to force the re-validation of a field in a form when another value in the same form is changed?

In AngularJS, how to force the re-validation of a field in a form when another value in the same form is changed?


By : Dvlop
Date : March 29 2020, 07:55 AM
wish help you to fix your issue I have done the same thing for validation of start-date on change of end-date. In the directive of start-date add watch for change of end-date and then call ngModel.$validate() in case end-date new value is defined.
code :
    scope.$watch(function () {
        return $parse(attrs.endDate)(scope);
    }, function () {
        ngModel.$validate();
    });
How can I check when certain form view is opened and field has changed in it on Odoo JavaScript?

How can I check when certain form view is opened and field has changed in it on Odoo JavaScript?


By : Syed Akber
Date : March 29 2020, 07:55 AM
I hope this helps . first of all you need to set class attribute to python filed in xml code. Ex:
code :
<field name="partner_id" class="class_partner" />
    odoo.define('partner_data.res_partner_widget', function(require) {
    "use strict";

        var core = require('web.core');
        var Dialog = require('web.Dialog');
        var form_common = require('web.form_common');
        var Widget = require('web.Widget');

        var Model = require('web.Model');

        var _t = core._t;
        var QWeb = core.qweb;
        var my_widget = Widget.extend({
            start: function () {
                this._super();  
                var self = this;
                $('body').on('change', '.class_partner',function() {
                    // Change value of other fields in this form
                   //you can call python function from here to set your value
                });
           },
        });
        core.action_registry.add('my_widget', my_widget);
        return my_widget;
    });
Update form with Validation not working until atleast one value is changed in the form field-Angular- ReactiveForms

Update form with Validation not working until atleast one value is changed in the form field-Angular- ReactiveForms


By : Samuel Ben Melki
Date : March 29 2020, 07:55 AM
this will help in app.module.ts import {RxReactiveFormsModule } from "@rxweb/reactive-form-validators"
imports:[ ...., RxReactiveFormsModule ]
code :
    import { Component, OnInit } from '@angular/core';
    import {FormGroup,FormControl,Validators } from "@angular/forms"
    import  {RxFormBuilder,FormGroupExtension } from "@rxweb/reactive-form-validators"

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.css' ]
})
export class AppComponent implements OnInit  {
  name = 'Angular';
  editForm:FormGroup;

  constructor(private formBuilder:RxFormBuilder){}

  ngOnInit(){

this.editForm = this.formBuilder.group({
      id:[1, Validators.required],
      name: ["Anil", [
        Validators.required,
        Validators.pattern(
          /^[A-Za-z]{1,16}([ ]?[a-zA-Z]{0,16})([ ]?[a-zA-Z]{0,16})$/
        )
      ]],
      designation: ["Software Engg", [
        Validators.required,
        Validators.pattern(
          /^[A-Za-z]{1,16}([ ]?[a-zA-Z]{0,16})([ ]?[a-zA-Z]{0,16})$/
        )
      ]]
    });

  }

  onSubmit() {
    console.log(this.editForm.value)
   let isDirty = (<FormGroupExtension>this.editForm).isDirty()

  }
}
<div class="container">
  <main class="col-12">
<h3 class="bd-title" id="content">Dirty Check Example</h3>
<br/>
<form [formGroup]="editForm" (ngSubmit)="onSubmit()" >
<div class="form-group">
    <label>Id</label>
    <input type="text" formControlName="id" class="form-control"  />
</div>
<div class="form-group">
    <label>Name</label>
    <input type="text" formControlName="name" class="form-control"  />
</div>
<div class="form-group">
    <label>Designation</label>
    <input type="text" formControlName="designation" class="form-control"  />
</div>
<button [disabled]="!(editForm.valid ||!editForm['isDirty']())" class="btn btn-primary">Update</button>
</form> 
</main></div>
Related Posts Related Posts :
  • Passing HttpServletResponse in Spring Boot controller method
  • Failed to load libraries: [netty_tcnative_linux_arm_32, netty_tcnative_linux_arm_32_fedora, netty_tcnative_arm_32, netty
  • How to build a small documents storage?
  • Getting pixel position of a text in an image
  • How do I get a list of Methods called from a Class in Eclipse IDE?
  • Convert string to day of week (not exact date)
  • Unable to understand how rounding is working for decimal digits (Java)
  • How to avoid java.lang.NoSuchMethodError: org.apache.poi.util.IOUtils.copy(Ljava/io/InputStream;Ljava/io/OutputStream;)
  • JTable Renderer not working with RowSorter?
  • From java.util.concurrent.Future<T> to play.libs.F.Promise<T>: How to do that in Java?
  • jUnit tests work in Eclipse, but fail in ant - java.lang.RuntimeException: Stub
  • How do i add a tooltip to existing gwt Textbox?
  • actor replying to non-actor
  • Google Cloud Messaging - server connection
  • Which classes are unmodifiable and cannot be intrumented and is there a way to bypass it?
  • Java & Jersey 1.17: Custom default response headers
  • Java rounding error
  • Setting custom RejectedExecutionHandler for ThreadPoolExecutor after executing some tasks?
  • Arquillian test class variables lose value
  • java.util.ConcurrentModificationException while inserting in ArrayList
  • How to write generic Java API without method Overloading
  • Java Serialization / Deserialization of an ArrayList works only on first program execution
  • Conway's Game of Life's rules dont apply properly
  • call a java method when Click on a html button without using javascript
  • Why does SSLSocketFactory.createSocket returns a Socket instead of SSLSocket?
  • How to schedule a task in Tomcat
  • compare two pdf files (approach) using java
  • What is the use of allowCoreThreadTimeout( ) in ThreadPoolExecutor?
  • Describe the Strategy Design Pattern in Java?
  • MongoDB too many open connections
  • Issue with generate JAXB classes with value constructors
  • Moving from one frame to another in java swing
  • Get a thread by Id
  • how to open front camera and back camera at same time?
  • Messed up with Java Declaration
  • Extracting chart in EXcel as image using java
  • How to get latitude and longitude in Android phone?
  • Do GC pauses and kill -STOP produce the same behavior?
  • Android HTML.ImageGetter Images resized
  • The way to instantiate map<String, List<String>> in Java
  • Java Making objects move while buttons held
  • Androidx Navigation View - `setNavigationItemSelectedListener` Doesn't Work
  • after compiling code JFrame does not appear
  • Netbeans project, JFrames ran from the main JFrame close all JFrames in project
  • Square Retrofit Client: How to enable/disable followRedirects? How to intercept redirect URL?
  • Java Circular Reference - Can’t Compile
  • Mouse click on specific time JAVA
  • android 4 onCreateDialog return type incompatible when overriding
  • Java Implementation of Oracle's DBMS_UTILITY.GET_HASH_VALUE Function
  • javac cannot be run, and furthermore does not seem installed
  • Function to obtain a thread given its ID
  • Java File path to Executable has spaces
  • Minimum Oracle Java VM heap memory setting?
  • Elegant way to create one of a large number of classes
  • Java fx binding styles
  • Summing weights based on string in large file
  • Android ListView setOnItemClickListener not working
  • How is the Java Bootstrap Classloader loaded?
  • Check object is blank
  • Add image between text in JEditorPane
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org