Skip to content
docsv0.1.0

AbstractFieldComponent

Shared mount/handle plumbing for the form field primitive family (input, textarea, select, checkbox): common `dirty`/`touched`/`error` state, and the four `change`/`blur`/`reset`/`set-error` actions every field supports. Concrete subclasses implement {@see contract()} and, when their value isn't a plain string (e.g. checkbox's boolean), override {@see valueKey()} / {@see initialValue()}.

AbstractFieldComponent::__construct()

public function __construct(?Milpa\Interfaces\Event\MilpaEventDispatcherInterface $dispatcher = null):

Parameters

Parameters of __construct()
NameTypeDescription
$dispatcher?Milpa\Interfaces\Event\MilpaEventDispatcherInterface

AbstractFieldComponent::contract()

abstract public static function contract(): Milpa\Live\ValueObjects\ComponentContract

The subclass's runtime contract (name, props/state schema, actions).

AbstractFieldComponent::mount()

public function mount(array $props, Milpa\Live\ValueObjects\ComponentContext $context): Milpa\Live\ValueObjects\StateSnapshot

Builds the initial state from {@see initialValue()} plus common `dirty`/`touched`/`error` fields, and captures `name`/`label`/ `required`/`disabled`/`hint`/`persistKey` props (merged with {@see meta()}) as mount-time meta.

Parameters

Parameters of mount()
NameTypeDescription
$propsarray<string, mixed>
$contextMilpa\Live\ValueObjects\ComponentContext

AbstractFieldComponent::handle()

public function handle(Milpa\Live\ValueObjects\InteractionRequest $request): Milpa\Live\ValueObjects\InteractionResult

Dispatches to `change`/`set` (aliases), `blur`, `reset`, and `set-error`; an unrecognized action is reported via {@see InteractionResult::$errors}.

Parameters

Parameters of handle()
NameTypeDescription
$requestMilpa\Live\ValueObjects\InteractionRequest