Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: withastro-utils/utils
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: @astro-utils/forms@3.13.11
Choose a base ref
...
head repository: withastro-utils/utils
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: @astro-utils/forms@3.13.12
Choose a head ref
  • 2 commits
  • 3 files changed
  • 2 contributors

Commits on Aug 16, 2024

  1. fix(files): parse multi file upload

    ido-pluto committed Aug 16, 2024
    Copy the full SHA
    0a5c0db View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    fa3e706 View commit details
Showing with 37 additions and 2 deletions.
  1. +28 −0 examples/simple-form/src/pages/multi-file-upload.astro
  2. +7 −0 packages/forms/CHANGELOG.md
  3. +2 −2 packages/forms/src/components-control/form-utils/parse.ts
28 changes: 28 additions & 0 deletions examples/simple-form/src/pages/multi-file-upload.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
import Layout from '../layouts/Layout.astro';
import {BButton, Bind, BindForm, BInput, FormErrors} from '@astro-utils/forms/forms.js';
import {Button} from 'reactstrap';
import 'bootstrap/dist/css/bootstrap.css';
type Form = {
files: File[];
}
const form = Bind<Form>();
let showSubmitText: string;
function formSubmit() {
showSubmitText = `You upload "${form.files.map(file => file.name).join(', ')}"`;
}
---
<Layout title="Upload file">
<BindForm bind={form}>
<FormErrors/>
{showSubmitText}

<h4>File to upload*</h4>
<BInput type="file" name="files" multiple/>

<BButton as={Button} props={{color: 'success'}} onClick={formSubmit} whenFormOK>Submit</BButton>
</BindForm>
</Layout>
7 changes: 7 additions & 0 deletions packages/forms/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [3.13.12](https://github.com/withastro-utils/utils/compare/@astro-utils/forms@3.13.11...@astro-utils/forms@3.13.12) (2024-08-16)


### Bug Fixes

* **files:** parse multi file upload ([0a5c0db](https://github.com/withastro-utils/utils/commit/0a5c0dbf49fef4b75a8ea3c4a2a25241ffa726b0))

## [3.13.11](https://github.com/withastro-utils/utils/compare/@astro-utils/forms@3.13.10...@astro-utils/forms@3.13.11) (2024-08-16)


4 changes: 2 additions & 2 deletions packages/forms/src/components-control/form-utils/parse.ts
Original file line number Diff line number Diff line change
@@ -163,12 +163,12 @@ async function isBigFile(value: string) {
export async function parseFiles(about: AboutFormName, astro: AstroGlobal, multiple: boolean, readonly: boolean) {
if (readonly) return;

const { disposeFiles } = getContext(astro, '@astro-utils/forms');
const { disposeFiles, bindId = '' } = getContext(astro, '@astro-utils/forms');
let values = [about.formValue];

let hasFailed = false;
if (multiple) {
values = about.formValue = await getFormMultiValue(astro.request, about.originalName);
values = about.formValue = await getFormMultiValue(astro.request, bindId + about.originalName);

const promises: Promise<any>[] = [];
for (let i = 0; i < values.length; i++) {