Skip to content

Commit cef5e74

Browse files
committed
Merge branch 'main' into feature/improvements
2 parents 3b01605 + 00206eb commit cef5e74

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

.github/workflows/fix-php-code-style-issues.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
ref: ${{ github.head_ref }}
2020

2121
- name: Fix PHP code style issues
22-
uses: aglipanci/laravel-pint-action@2.4
22+
uses: aglipanci/laravel-pint-action@2.5
2323

2424
- name: Commit changes
2525
uses: stefanzweifel/git-auto-commit-action@v5

src/Concerns/CanMapDynamicFields.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,19 @@ protected function mutateFormData(array $data, callable $mutationStrategy): arra
9999
return $data;
100100
}
101101

102-
private function resolveFormFields(): array
102+
private function resolveFormFields(?Model $record = null): array
103103
{
104-
if (! isset($this->record) || $this->record->fields->isEmpty()) {
104+
105+
$record = $record ?? $this->record;
106+
107+
if (! isset($record->fields) || $record->fields->isEmpty()) {
105108
return [];
106109
}
107110

108111
$customFields = $this->resolveCustomFields();
109112

110-
return $this->record->fields
111-
->map(fn ($field) => $this->resolveFieldInput($field, $customFields))
113+
return $record->fields
114+
->map(fn($field) => $this->resolveFieldInput($field, $customFields))
112115
->filter()
113116
->values()
114117
->all();
@@ -117,12 +120,14 @@ private function resolveFormFields(): array
117120
private function resolveCustomFields(): Collection
118121
{
119122
return collect(Fields::getFields())
120-
->map(fn ($fieldClass) => new $fieldClass);
123+
->map(fn($fieldClass) => new $fieldClass);
121124
}
122125

123-
private function resolveFieldInput(Model $field, Collection $customFields): ?object
126+
private function resolveFieldInput(Model $field, Collection $customFields, ?Model $record = null): ?object
124127
{
125-
$inputName = "{$this->record->valueColumn}.{$field->ulid}";
128+
$record = $record ?? $this->record;
129+
130+
$inputName = "{$record->valueColumn}.{$field->ulid}";
126131

127132
// Try to resolve from standard field type map
128133
if ($fieldClass = self::FIELD_TYPE_MAP[$field->field_type] ?? null) {

src/Fields/Repeater.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public static function getDefaultConfig(): array
5555
'collapsible' => false,
5656
'collapsed' => false,
5757
'cloneable' => false,
58+
'columns' => 1,
5859
'form' => [],
5960
];
6061
}
@@ -69,7 +70,8 @@ public static function make(string $name, ?Field $field = null): Input
6970
->deletable($field->config['deletable'] ?? self::getDefaultConfig()['deletable'])
7071
->reorderable($field->config['reorderable'] ?? self::getDefaultConfig()['reorderable'])
7172
->collapsible($field->config['collapsible'] ?? self::getDefaultConfig()['collapsible'])
72-
->cloneable($field->config['cloneable'] ?? self::getDefaultConfig()['cloneable']);
73+
->cloneable($field->config['cloneable'] ?? self::getDefaultConfig()['cloneable'])
74+
->columns($field->config['columns'] ?? self::getDefaultConfig()['columns']);
7375

7476
if ($field->config['reorderableWithButtons'] ?? self::getDefaultConfig()['reorderableWithButtons']) {
7577
$input = $input->reorderableWithButtons();
@@ -124,6 +126,10 @@ public function getForm(): array
124126
->inline(false),
125127
Forms\Components\TextInput::make('config.addActionLabel')
126128
->label(__('Add action label')),
129+
Forms\Components\TextInput::make('config.columns')
130+
->label(__('Columns'))
131+
->default(1)
132+
->numeric(),
127133
AdjacencyList::make('config.form')
128134
->columnSpanFull()
129135
->label(__('Fields'))

0 commit comments

Comments
 (0)