Skip to main content

toBehaviorFieldPath()

function toBehaviorFieldPath<TForm, TField>(fieldPath): FieldPath<TField>;

Defined in: core/behavior/compose-behavior.ts:46

ΠŸΡ€Π΅ΠΎΠ±Ρ€Π°Π·ΠΎΠ²Π°Ρ‚ΡŒ FieldPath Π²ΠΎ Π²Π»ΠΎΠΆΠ΅Π½Π½Ρ‹ΠΉ ΠΏΡƒΡ‚ΡŒ для ΠΊΠΎΠΌΠΏΠΎΠ·ΠΈΡ†ΠΈΠΈ behavior схСм

Аналог toFieldPath из validation API.

Type Parameters​

TForm​

TForm

TField​

TField

Parameters​

fieldPath​

ПолС для прСобразования

FieldPathNode<TForm, TField, unknown> | undefined

Returns​

FieldPath<TField>

Π’Π»ΠΎΠΆΠ΅Π½Π½Ρ‹ΠΉ FieldPath

Example​

// address-behavior.ts
export const addressBehavior = (path: FieldPath<Address>) => {
watchField(path.country, async (country, ctx) => {
const regions = await fetchRegions(country);
ctx.updateComponentProps(path.region, { options: regions });
});
};

// user-behavior.ts
export const userBehavior = (path: FieldPath<User>) => {
// ΠšΠΎΠΌΠΏΠΎΠ·ΠΈΡ†ΠΈΡ: примСняСм addressBehavior ΠΊ Π²Π»ΠΎΠΆΠ΅Π½Π½ΠΎΠΌΡƒ полю
addressBehavior(toBehaviorFieldPath(path.address));
};