Skip to content

Commit

Permalink
Added the ability to set the name of the input field for files
Browse files Browse the repository at this point in the history
  • Loading branch information
simba77 committed Feb 10, 2024
1 parent 9bfbd8c commit 5348833
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
13 changes: 13 additions & 0 deletions system/src/Forms/Inputs/CKEditor.php
Expand Up @@ -16,4 +16,17 @@ class CKEditor extends AbstractInput
{
public string $type = 'ckeditor';
public string $uploadUrl = '';
public string $filesInputName = 'attached_files[]';

public function setUploadUrl(string $uploadUrl): static
{
$this->uploadUrl = $uploadUrl;
return $this;
}

public function setFilesInputName(string $filesInputName): static
{
$this->filesInputName = $filesInputName;
return $this;
}
}
6 changes: 5 additions & 1 deletion themes/admin/src/js/components/CkeditorInputComponent.vue
Expand Up @@ -6,7 +6,7 @@
<div class="invalid-feedback d-block" v-if="errors">{{ errors }}</div>
</div>
<div v-for="(file, index) in attached_files" :key="index">
<input type="hidden" name="attached_files[]" v-model="file.id">
<input type="hidden" :name="filesInputName" v-model="file.id">
</div>
</div>
</template>
Expand All @@ -24,6 +24,10 @@ export default {
type: String,
default: ''
},
filesInputName: {
type: String,
default: 'attached_files[]'
},
name: {
type: String,
default: ''
Expand Down
17 changes: 9 additions & 8 deletions themes/admin/templates/system/forms/ckeditor.blade.php
Expand Up @@ -13,13 +13,14 @@
<script src="<?= asset('ckeditor5/ckeditor.js', true) ?>"></script>
<div class="vue_app">
<ckeditor-input-component
upload_url="<?= $field->uploadUrl ?>"
name="{{ $field->name }}"
language="<?= $locale ?>"
errors="{!! implode('<br>', $errors[$field->name] ?? []) !!}"
id="{{$field->id}}"
label="{{$field->label}}"
value="{{$field->value}}"
csrf_token="<?= $csrf_token ?>"
upload_url="<?= $field->uploadUrl ?>"
name="{{ $field->name }}"
language="<?= $locale ?>"
errors="{!! implode('<br>', $errors[$field->name] ?? []) !!}"
id="{{$field->id}}"
label="{{$field->label}}"
value="{{$field->value}}"
csrf_token="{{$csrf_token}}"
files-input-name="{{ $field->filesInputName }}"
></ckeditor-input-component>
</div>

0 comments on commit 5348833

Please sign in to comment.