createRepeatInstance method

void createRepeatInstance(
  1. FormInstance mainInstance,
  2. EvaluationContext ec,
  3. TreeReference createdRef,
  4. TreeElement createdElement,
)

Updates the form after the repeat instance createdElement was added at createdRef.

Implementation

void createRepeatInstance(
  FormInstance mainInstance,
  EvaluationContext ec,
  TreeReference createdRef,
  TreeElement createdElement,
) {
  final affectAll = _triggerablesAffectingAllInstances(
    createdRef.genericize(),
  );
  // Conditions depending on the new node's existence (count(), …).
  final phase1 = triggerTriggerables(mainInstance, ec, createdRef, affectAll);
  publishSummary('Created (phase 1)', createdRef, phase1);
  // Conditions of the node and its descendants.
  final phase2 = initializeTriggerables(mainInstance, ec, createdRef);
  publishSummary('Created (phase 2)', createdRef, phase2);
  _evaluateChildrenTriggerables(mainInstance, ec, createdElement, {
    ...phase1,
    ...phase2,
  }, created: true);
}