Skip to content

Commit

Permalink
feat(form): use _self instead of __self #25
Browse files Browse the repository at this point in the history
  • Loading branch information
Awilum committed Jun 2, 2021
1 parent 9e7f9d2 commit 7d5b321
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions app/Models/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,37 +106,37 @@ public function getFields(): array
switch ($field['type']) {
case 'bool':
if (isset($field['value'])) {
$data[$field['name']] = strings(flextype('twig')->fetchFromString(strings($field['value'])->replace('__self.value', "'". arrays($this->data)->get($field['name']) . "'"), isset($field['data']) ? $field['data'] : []))->toBoolean();
$data[$field['name']] = strings(flextype('twig')->fetchFromString(strings($field['value'])->replace('_self.value', "'". arrays($this->data)->get($field['name']) . "'"), isset($field['data']) ? $field['data'] : []))->toBoolean();
} else {
$data[$field['name']] = strings(arrays($this->data)->get($field['name']))->toBoolean();
}
break;
case 'float':
if (isset($field['value'])) {
$data[$field['name']] = strings(flextype('twig')->fetchFromString(strings($field['value'])->replace('__self.value', "'". arrays($this->data)->get($field['name']) . "'"), isset($field['data']) ? $field['data'] : []))->toFloat();
$data[$field['name']] = strings(flextype('twig')->fetchFromString(strings($field['value'])->replace('_self.value', "'". arrays($this->data)->get($field['name']) . "'"), isset($field['data']) ? $field['data'] : []))->toFloat();
} else {
$data[$field['name']] = strings(arrays($this->data)->get($field['name']))->toFloat();
}
break;
case 'int':
if (isset($field['value'])) {
$data[$field['name']] = strings(flextype('twig')->fetchFromString(strings($field['value'])->replace('__self.value', "'". arrays($this->data)->get($field['name']) . "'"), isset($field['data']) ? $field['data'] : []))->toInteger();
$data[$field['name']] = strings(flextype('twig')->fetchFromString(strings($field['value'])->replace('_self.value', "'". arrays($this->data)->get($field['name']) . "'"), isset($field['data']) ? $field['data'] : []))->toInteger();
} else {
$data[$field['name']] = strings(arrays($this->data)->get($field['name']))->toInteger();
}
break;
default:
case 'string':
if (isset($field['value'])) {
$data[$field['name']] = strings(flextype('twig')->fetchFromString(strings($field['value'])->replace('__self.value', "'". arrays($this->data)->get($field['name']) . "'"), isset($field['data']) ? $field['data'] : []))->toString();
$data[$field['name']] = strings(flextype('twig')->fetchFromString(strings($field['value'])->replace('_self.value', "'". arrays($this->data)->get($field['name']) . "'"), isset($field['data']) ? $field['data'] : []))->toString();
} else {
$data[$field['name']] = strings(arrays($this->data)->get($field['name']))->toString();
}
break;
}
} else {
if (isset($field['value'])) {
$data[$field['name']] = flextype('twig')->fetchFromString(strings($field['value'])->replace('__self.value', "'". arrays($this->data)->get($field['name']) . "'"), isset($field['data']) ? $field['data'] : []);
$data[$field['name']] = flextype('twig')->fetchFromString(strings($field['value'])->replace('_self.value', "'". arrays($this->data)->get($field['name']) . "'"), isset($field['data']) ? $field['data'] : []);
} else {
$data[$field['name']] = arrays($this->data)->get($field['name']);
}
Expand Down Expand Up @@ -178,13 +178,13 @@ public function getActions()
$properties = array_values($action['properties']);
foreach ($properties as $key => $field) {
switch ($field) {
case '__self.fields':
case '_self.fields':
$properties[$key] = $this->getFields();
break;
case '__self.messages':
case '_self.messages':
$properties[$key] = $this->getMessages();
break;
case '__self.redirect':
case '_self.redirect':
$properties[$key] = $this->getFields();
break;
default:
Expand Down

0 comments on commit 7d5b321

Please sign in to comment.