Skip to content

Commit

Permalink
feat(template): pass optional data to field depending on field type
Browse files Browse the repository at this point in the history
Signed-off-by: Elizabeth Danzberger <[email protected]>
  • Loading branch information
elzody committed Aug 26, 2024
1 parent 52cc761 commit 031835c
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions lib/Service/TemplateFieldService.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,23 @@ public function extractFields(Node|int $file): array {
continue;
}

$fields[] = [
new Field(
$index,
$attr['content'],
$fieldType,
$attr['alias'],
$attr['id'],
$attr['tag']
)
];
$field = new Field($index, $fieldType);
$field->id = $attr["id"];
$field->tag = $attr["tag"];
$field->alias = $attr["alias"];

switch ($fieldType) {
case FieldType::RichText:
$field->content = $attr["content"];
break;
case FieldType::CheckBox:
$field->checked = ($attr["Checked"] === "true");
break;
default:
break;
}

$fields[] = [$field];
}

$fields = array_merge([], ...$fields);
Expand Down

0 comments on commit 031835c

Please sign in to comment.