Giter VIP home page Giter VIP logo

Comments (5)

vasilich6107 avatar vasilich6107 commented on August 16, 2024 1

Hi.
Check the updated example
4b03e55

from reactive_forms_generator.

vasilich6107 avatar vasilich6107 commented on August 16, 2024 1

There is no ability to access parent in current implementation.
you can refer to statically generated control names in your validators
https://github.com/artflutter/reactive_forms_generator/blob/master/packages/reactive_forms_generator/example/lib/docs/login/login.gform.dart#L180

from reactive_forms_generator.

tomwyr avatar tomwyr commented on August 16, 2024

@vasilich6107 Is there a way to obtain the generated form object from a form control? That would allow operating on the controls safely. Otherwise, you kinda lose the benefits of code generation (control names, casting types, finding nested controls).

from reactive_forms_generator.

vasilich6107 avatar vasilich6107 commented on August 16, 2024

hi. The thing is that

'Prefer not to call `model` on non-valid form it could cause unexpected exceptions 
in case you created a non-nullable field 
in model and expect it to be guarded by some kind of `required` validator.',

Let's say you have String(non nullable field) in your model, it is guarded by required validator.
at the time you are calling mustMatch the counterpart field could be null and it will have an exception due to the casting of String? to String

from reactive_forms_generator.

tomwyr avatar tomwyr commented on August 16, 2024

Thanks @vasilich6107 I see what's the concern. I think I'm not talking about reading form model values from a control but, rather than that, accessing other field controls in a typesafe way. So instead of doing:

FormControl<Field2ValueType> getField2Control(FormControl field1Control) {
    final formGroup = field1Control.parent as FormGroup;
    final field2Control = formGroup.control('field2ControlName');
    return field2Control as FormControl<Field2ValueType>;
}

There would be something like:

FormControl<Field2ValueType> getField2Control(FormControl field1Control) {
    return field1Control.parent.field2Control;
}

I guess that's a completely new feature (assuming it would be possible) and not a trivial change.

from reactive_forms_generator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.