Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

alpinejs-form-data

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alpinejs-form-data

Get the data from the form in a key/value pair of name and value 🥯

  • 1.0.4
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
169
decreased by-2.87%
Maintainers
1
Weekly downloads
 
Created
Source

Alpine JS Form Data

Get the data from the form in a key/value pair of name and value 🥯

Install

With a CDN

<script
  defer
  src="https://unpkg.com/alpinejs-form-data@latest/dist/form-data.min.js"
></script>

<script defer src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js"></script>

With a Package Manager

yarn add -D alpinejs-form-data

npm install -D alpinejs-form-data
import Alpine from 'alpinejs'
import formData from 'alpinejs-form-data'

Alpine.plugin(formData)

Alpine.start()

Example

<form x-data x-on:submit.prevent="console.log($formData)">
  <input type="text" name="title" />
  <input type="text" name="slug" />
  <button>Submit</button>
</form>

On submit this will return the following:

{title: 'My New Blog Post', slug: 'my-new-blog-post'}

Returning Data as Array

You may want the data returned to be a nested array:

[
  ['title', 'My New Blog Post'],
  ['slug', 'my-new-blog-post'],
]

To do this you can use $formDataArray instead of $formData.

Stats

Keywords

FAQs

Package last updated on 04 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc