Giter Club home page Giter Club logo

Comments (11)

hoermillerj avatar hoermillerj commented on June 20, 2024 1

@simfyz to answer your question. I simply added a subscription to the value change for the formControl (in this example "firstName") and then added a required validator to the formControls that should be required conditionally.

from rxweb.

simfyz avatar simfyz commented on June 20, 2024 1

@ajayojha Thanks for the headsup. I found that it's not imported in the root module, rather to shared module and imported along the feature modules. I think after the changes as you mentioned, it is working as I found, now it is passed to the QAs to be verified. I will update if I find any issues here on.
I'm interested to see what @hoermillerj 's findings.

from rxweb.

simfyz avatar simfyz commented on June 20, 2024

@ajayojha is there any updates on this issue? I'm having the same issue.
@hoermillerj did you find a workaround on this?

from rxweb.

ajayojha avatar ajayojha commented on June 20, 2024

I did check in the past but forgot to update here, Please refer to this link, I think it's working as expected

from rxweb.

simfyz avatar simfyz commented on June 20, 2024

I did check in the past but forgot to update here, Please refer to this link, I think it's working as expected

@ajayojha I think this has a conflict of API or issue with IVY. In youe example, it is version ANgular v 7. Please refer the example StackBlitz by @hoermillerj , it's Angular 7 and has the issue. I'm also on v13.

from rxweb.

hoermillerj avatar hoermillerj commented on June 20, 2024

@ajayojha I checked your gist and it seems like you are using an older version of Angular as @simfyz pointed out. I created a new version of my StackBlitz link here to incorporate your style (here), but unfortunately the results are the same. The required validator only takes effect after the value of "middleName" or "lastName" has been changed and then removed again.

from rxweb.

ajayojha avatar ajayojha commented on June 20, 2024

@hoermillerj & @simfyz thanks for pointing it out. I will look into this and fix it soon.

from rxweb.

simfyz avatar simfyz commented on June 20, 2024

@simfyz to answer your question. I simply added a subscription to the value change for the formControl (in this example "firstName") and then added a required validator to the formControls that should be required conditionally.

Thanks. I did write my own custom validator to achieve this. Not the cleanest way. I will wait till a fix from @ajayojha

from rxweb.

ajayojha avatar ajayojha commented on June 20, 2024

@hoermillerj I have checked the shared stackblitz link and identified the cause of this issue. It's not related to lib, You have missed importing the RxReactiveFormsModule in the root module. that's the reason conditional validation is not working. Please refer to this updated code example.

Here is the changed code snippet:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { RxReactiveFormsModule } from '@rxweb/reactive-form-validators';
import { AppComponent } from './app.component';

@NgModule({
  imports: [
    BrowserModule,
    FormsModule,
    ReactiveFormsModule,
    RxReactiveFormsModule,
  ],
  declarations: [AppComponent],
  bootstrap: [AppComponent],
})
export class AppModule {}

@simfyz Please check in your project whether the RxReactiveFormsModule is imported or not.

I am not closing this ticket until getting the green signal from you guys (@hoermillerj & @simfyz ) :).

from rxweb.

simfyz avatar simfyz commented on June 20, 2024

@ajayojha Looks like the issue is still persisting. I have check box inside the form array. if the check box value is true, another value is required. The conditonalExpression is firing only at the initalization. After that it fires when the checkbox is checked. When unchecked it's not firing the conditional expression. I did import in the root module.

from rxweb.

ajayojha avatar ajayojha commented on June 20, 2024

@simfyz Please share the stackblitz URL of the issue example.

from rxweb.

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.