Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 15:21
    MaxKless commented #3369
  • 14:11
    chavilax commented #3369
  • 12:51
    MaxKless commented #3360
  • 12:46
    MaxKless commented #3369
  • Jul 05 18:56
    aitboudad closed #3372
  • Jul 05 18:56
    aitboudad commented #3372
  • Jul 05 17:54
    jsofii commented #3372
  • Jul 05 17:52
    jsofii commented #3372
  • Jul 05 17:37
    aitboudad commented #3372
  • Jul 05 17:26
    jsofii opened #3372
  • Jul 05 17:26
    jsofii labeled #3372
  • Jul 05 12:40
    aitboudad closed #3371
  • Jul 05 12:40
    aitboudad commented #3371
  • Jul 05 12:26
    dsriniv opened #3371
  • Jul 05 12:26
    dsriniv labeled #3371
  • Jul 05 12:03
    chavilax commented #3369
  • Jul 05 08:59
    chavilax commented #3369
  • Jul 05 07:02
    chavilax closed #3370
  • Jul 04 15:29
    aitboudad commented #3340
  • Jul 04 14:38
    elnipa commented #3340
Abdellatif Ait boudad
@aitboudad
@intellix ngOnInit else for postPopulate step you can rely field.model instead
Stack 0
@StekovicN_twitter
Hi there, i'm having validation messages that needs to be translated. What i do now is that i use FieldConfig service and translate these on language change which works fine. Tricky part is when we already have shown validation messages and user changes language, how do i trigger these to update translations on already shown validation messages? It works if for example if i change some field and trigger .markAllAsTouched() again and that would work but how would i do it inside my service where i set translations on validation messages? I need some generic solution to handle it
Abdellatif Ait boudad
@aitboudad
Stack 0
@StekovicN_twitter
nice one, looks good... going to investigate more on this one... cheers
Stack 0
@StekovicN_twitter
stream solved it and this solution works amazing.. thanks
lorenzonet
@lorenzonet
Hello there, anyone has tried to use NosDB an Open Source NoSQL Database for .NET?
Anoop Chauhan
@anoop0567
Hi, i'm new on ngx-formly and trying to use this on angular 5 project but getting this error on console ERROR Error: [Formly Error] There is no type by the name of "input" , please help me to resolve this issue
I have followed these steps
  1. Install Formly package: npm i @ngx-formly/core@3.x
  2. add <formly-form> inside the form tag to your AppComponent template
  3. configure defined form
Bojan Mickoski
@bmickoski
@anoop0567 I think you need to install some of predefined UI themes. For example try importing FormlyBootstrapModule in your module or if you don't want to use predefined you will need to create custom formly input and register in FormlyModule.forRoot.
Anoop Chauhan
@anoop0567
Okay, thanks for your response @BukicMicko :thumbsup:
Jonathan Gomes
@jongomes
I would like ng zorro to be compatible with version 11 of the angular
dwelchtransitpros
@dwelchtransitpros

I have a weird error happening seemingly randomly. When I use hide expression, sometimes the field hides and I get this error:

Cannot read property 'length' of undefined at FieldExpressionExtension.push../node_modules/@ngx-formly/core/fesm5/ngx-formly-core.js.FieldExpressionExtension.toggleFormControl (ngx-formly-core.js:3012).

hideExpression: (model) => model.serviceType === 'somevalue'

It looks like it's losing the _fields attribute somehow. But it doesn't happen to all fields. I can't replicate it on plunker or anything else. Any ideas of something to check?

dwelchtransitpros
@dwelchtransitpros
Sort of figured it out. Was setting model values before the form was loaded causing the formly control builder to not add the '_fields' attribute... somehow.
Bojan Mickoski
@bmickoski

@aitboudad How can I exclude main wrapper for one field. For example i have two custom wrappers, one which overrides default form-field and another one.

    wrappers: [
         {
            name: 'form-field',
            component: AcWrapperFormField,
        },
        {
            name: 'form-field-inline',
            component: AcWrapperFormFieldInline,
        },
    ],

types: [
        {
            name: 'input',
            component: AcInputFieldComponent,
            wrappers: ['form-field'],
        },
        {
            name: 'textarea',
            component: AcTextAreaFieldComponent,
            wrappers: ['form-field'],
        },
        {
            name: 'checkbox',
            component: AcCheckboxFieldComponent,
            wrappers: ['form-field-inline'],
        },
       .....

What i need is only AcCheckboxFieldComponent to use form-field-inline and all other types form-field. But issue is that both wrappers are applied for AcCheckboxFieldCompoenent

image.png
Abdellatif Ait boudad
@aitboudad
@BukicMicko probably a bug, could you please fill an issue in Formly repo with a small reproduction
Bojan Mickoski
@bmickoski

Hm... @aitboudad i tried to create quick stackblitz example.. and seems to be working fine.... https://stackblitz.com/edit/angular-6d8efg-6iffnj?file=src%2Fapp%2Fapp.component.html.

Maybe something is messed up in my project.. will double check :)

2 replies
Ash McConnell
@AshMcConnell_twitter
Hi Folks, I've just started using formly and I'm having trouble getting any kind of custom validator to work. I must be missing something
{
                    key: 'surname',
                    type: 'input',
                    className: 'flex-50',
                    templateOptions: {
                        label: 'Surname',
                        required: true
                    },
                    validators: {
                        validation: [(something) => {
                            console.log('validating', something);
                            return false;
                        }]
                    },
                },
I only get the console message when the form first loads, but not when I change the content or blur off
Have I missed a step?
Ash McConnell
@AshMcConnell_twitter
(This is within a fieldGroup if that matters)
Ash McConnell
@AshMcConnell_twitter
Ash McConnell
@AshMcConnell_twitter
Got the issue, I was using the same form for 2 parts of the page (I thought that would work)
Stack 0
@StekovicN_twitter
Hei @aitboudad why does validation remain on the field when we re-render it to the DOM, am i doing something wrong? Made small stackblitz demo to demonstrate https://stackblitz.com/edit/angular-gpnlq9-12goss?file=src/app/app.component.ts . You can see that validation is set first field only, but it remains on second even though it does not have validation set to it... not sure if this is expected?
4 replies
Stack 0
@StekovicN_twitter
i get it, it observes the same key :/ once we change key, it changes validator and everything works fine
Stack 0
@StekovicN_twitter
how can we achieve having same key instead of doing dirty hacks? :)
anushreenk
@anushreenk
he wrapper "fieldset" could not be found. Please make sure that is registered through the FormlyModule declaration. Why i must be getting issue
Is date range picker is possible in ngx-formly
anushreenk
@anushreenk
image.png
image.png
image.png
can someone help why I am getting the error
what wrong i am doing @aitboudad
Stack 0
@StekovicN_twitter
@anushreenk wrapper: ["label"] does not exist... you just wrote it there but it is not registered... you need to make wrapper and register it like this https://github.com/ngx-formly/ngx-formly/blob/main/src/ui/bootstrap/form-field/src/form-field.module.ts
anushreenk
@anushreenk
but how its working in this exampple
anushreenk
@anushreenk
@StekovicN_twitter Thanks I have created the wrapper and included that in my module.It worked for me
Bojan Mickoski
@bmickoski

@aitboudad is it possible to provide functions as string for expressionProperties and then evaluate them as function where we need to use. Something like

              this.fieldConfig.hideExpression =
                 '(model: any, formState: any, field: FormlyFieldConfig) => { if (this.fieldConfig.model.value) { return !( formState.mainModel[this.fieldConfig.model.component] && formState.mainModel[this.fieldConfig.model.component] === this.fieldConfig.model.value ); } else {  return !formState.mainModel[this.fieldConfig.model.component];  } },';

Idea is to use string for expression props and then evaluate with typescript something like:
https://stackoverflow.com/questions/45153848/evaluate-typescript-from-string
thing is i need to interpolate values from this inside string like this.fieldConfig.model.value.. etc.. If i first try to execute logic simply as function and then try to stringify

this.fieldConfig.expressionProperties = JSON.stringify(this.fieldConfig.expressionProperties);

ngx formly of course complains cause we cannot use string for hideExpression.

1 reply
farakk
@farakk

@aitboudad. Please I want to click on any step and fire (selectionChange)="selectionChanged($event)".

<mat-horizontal-stepper (selectionChange)="selectionChanged($event)" #stepperauto>
<mat-step *ngFor="let step of field.fieldGroup; let index = index; let last = last;">
<ng-template matStepLabel>
{{ step.templateOptions.label}}
</ng-template>
<router-outlet *ngIf="index === selectedStep"></router-outlet>
</mat-step>
</mat-horizontal-stepper>

public selectedStep: number = 0;
steps: any[];
data : any[];
fields: FormlyFieldConfig[];

ngOnInit() {

 ////this.steps = this.route.snapshot.routeConfig.children.map(child  => { return child.path });  //breaking

this.steps = this.route.snapshot.data.children.map(child  => { return child.path }); //breaking
let step = this.field.fieldGroup[0];
this.router.navigate([step], { relativeTo: this.route });

}

selectionChanged(event: any) {
this.selectedStep = event.selectedIndex;
this.router.navigate([this.field.fieldGroup[this.selectedStep]],{relativeTo:this.route});
}

6 replies
Ash McConnell
@AshMcConnell_twitter
Hi Folks, is it possible to use formly configuration to add a directive? I tried adding it as an attribute using templateOptions, but it doesn't get picked up
Abdellatif Ait boudad
@aitboudad
@AshMcConnell_twitter not possible, Angular doesn't support that yet.
Ash McConnell
@AshMcConnell_twitter
@aitboudad thanks!
Dominic Watson
@intellix
having an issue where the this isn't correct in my expressionProperties getter
prePopulate(field: FormlyFieldConfig) {
  field.fieldGroup = [
    {
      key: 'account',
      type: 'payment-card-form',
      expressionProperties: {
        hide: () => {
          console.log(this.state);
          return this.state === 'selector';
        },
this.state is always undefined, despite being set on the class. If I set it initially, it's the initial value at construct but doesn't update
Philip
@PhilipSh
hi, anybody know how i can mark formGroup asTouched after init formly form?
i need mark invalid fields
Stefan Bakic
@sbakic
@PhilipSh It looks like you want to force validation on init form. Check this https://formly.dev/examples/validation/force-show-error
Bo
@demonbo
hello Guys, i want to ask about hideExpression in formly
is it equal to ngIf in angular or ngShow?