aitboudad on v6.0.0-beta.2
aitboudad on main
fix(material): add null check f… fix(core): keep display: none f… fix(bootstrap): updates dirty s… and 3 more (compare)
aitboudad on v5.12.3
aitboudad on v5
chore(release): 5.12.3 (compare)
aitboudad on v5
fix(bootstrap): updates dirty s… (compare)
aitboudad on v5
fix(bootstrap): updates dirty s… (compare)
aitboudad on v5
fix(core): keep display: none f… (compare)
aitboudad on v5
fix(material): add null check f… (compare)
@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
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 :)
{
key: 'surname',
type: 'input',
className: 'flex-50',
templateOptions: {
label: 'Surname',
required: true
},
validators: {
validation: [(something) => {
console.log('validating', something);
return false;
}]
},
},
@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.
@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});
}
prePopulate(field: FormlyFieldConfig) {
field.fieldGroup = [
{
key: 'account',
type: 'payment-card-form',
expressionProperties: {
hide: () => {
console.log(this.state);
return this.state === 'selector';
},
lazyRender
to true
, it was part of v5.10.0 release (will be enabled by default in v6
)
yarn demo
I got a bunch of errors (e.g. Error: src/ui/primeng/checkbox/src/checkbox.module.ts:11:17 - error NG1010: Value at position 0 in the NgModule.declarations of FormlyCheckboxModule is not a reference
Value could not be determined statically.
or src/ui/primeng/checkbox/src/checkbox.module.ts:32:14 - error NG6002: Appears in the NgModule.imports of FormlyPrimeNGModule, but could not be resolved to an NgModule class.
). Any idea of what is going on?@aleixsuau not sure what's going on there 🤔, try to remove node_modules folder and use npm
instead of yarn:
npm install
npm run start
the doc doesn't require running the demo, so just edit the markdown files https://github.com/ngx-formly/ngx-formly/tree/main/demo/src/app/guides in case you still having those issues