All Projects → dwyl → autoform

dwyl / autoform

Licence: GPL-2.0 license
🤖📝 AutoForm is the simplest way to automatically generate fast, beautiful and standards/WCAG compliant HTML forms based on an Ecto Schema in a Phoenix Web Application to *significantly* speed up Web App Development. 🚀

Programming Languages

elixir
2628 projects
HTML
75241 projects

Projects that are alternatives of or similar to autoform

phx raws
Raw websocket server on top of Phoenix.
Stars: ✭ 27 (+50%)
Mutual labels:  elixir-phoenix, phoenix-framework
react-inputs-validation
A react component for form inputs validation. Online demo examples
Stars: ✭ 48 (+166.67%)
Mutual labels:  form, form-validation
Form bloc
🔥 Dart and Flutter Package 🔥 Easy Form State Management using BLoC pattern 🔥 Wizard/stepper forms, asynchronous validation, dynamic and conditional fields, submission progress, serialization and more! 🔥
Stars: ✭ 239 (+1227.78%)
Mutual labels:  form, form-validation
Elm Form
Dynamic forms handling in Elm
Stars: ✭ 189 (+950%)
Mutual labels:  form, form-validation
form-data-json
A zero dependency, cross browser library to easily get or set/manipulate form input values as/from a json object.
Stars: ✭ 37 (+105.56%)
Mutual labels:  form, form-validation
Material Singleinputform
A single EditText instead of a classical form. Library that implements flavienlaurent's singleinputform
Stars: ✭ 202 (+1022.22%)
Mutual labels:  form, form-validation
FrontendForms
A module for ProcessWire CMS to create and validate forms on the frontend easily using the Valitron library.
Stars: ✭ 0 (-100%)
Mutual labels:  form, form-validation
Neoform
✅ React form state management and validation
Stars: ✭ 162 (+800%)
Mutual labels:  form, form-validation
react-cool-form
😎 📋 React hooks for forms state and validation, less code more performant.
Stars: ✭ 246 (+1266.67%)
Mutual labels:  form, form-validation
ATGValidator
iOS validation framework with form validation support
Stars: ✭ 51 (+183.33%)
Mutual labels:  form, form-validation
Redux Form
A Higher Order Component using react-redux to keep form state in a Redux store
Stars: ✭ 12,597 (+69883.33%)
Mutual labels:  form, form-validation
antd-react-form-builder
Example
Stars: ✭ 74 (+311.11%)
Mutual labels:  form, form-validation
Composable Form
Build type-safe composable forms in Elm
Stars: ✭ 179 (+894.44%)
Mutual labels:  form, form-validation
Resolvers
📋 Validation resolvers: Zod, Yup, Joi, Superstruct, and Vest.
Stars: ✭ 222 (+1133.33%)
Mutual labels:  form, form-validation
Sveltejs Forms
Declarative forms for Svelte
Stars: ✭ 163 (+805.56%)
Mutual labels:  form, form-validation
Final Form
🏁 Framework agnostic, high performance, subscription-based form state management
Stars: ✭ 2,787 (+15383.33%)
Mutual labels:  form, form-validation
Formhelper
ASP.NET Core - Transform server-side validations to client-side without writing any javascript code. (Compatible with Fluent Validation)
Stars: ✭ 155 (+761.11%)
Mutual labels:  form, form-validation
Yaaf
Easing the form object pattern in Rails applications
Stars: ✭ 161 (+794.44%)
Mutual labels:  form, form-validation
live dj
💿 Join or create video playlists to share a real-time experience with others! 🎧
Stars: ✭ 19 (+5.56%)
Mutual labels:  elixir-phoenix, phoenix-framework
ember-validity-modifier
Ember Octane addon to add custom validity (form validation) to form fields
Stars: ✭ 28 (+55.56%)
Mutual labels:  form, form-validation

af

Auto Form ("af") is a way of generating standards/WCAG compliant HTML forms based on an Ecto Schema.

Usage

Add autoform to your mix.exs

defp deps do
    [
      {:autoform, "~> 0.1.0"}
    ]
  end

Autoform can be used from either a Phoenix View, or Phoenix Controller.

You'll need to add

use Autoform

to the top of the module you want to use it in.

You'll be able to call either render_autoform/4 or custom_render_autoform/4 in the controller, or the template that corresponds to the view.

Call render_autoform in your controller with:

render_autoform(conn, :update, User, assigns: [user: get_user_from_db()])

or in your template:

<%= render_autoform(@conn, :create, User, assigns: [changeset: @changeset)], exclude: :date_of_birth %>

custom_render_autoform is called in a very similar way, but can be given extra arguments which will change the generated form.

An example of this in a template:

<%= custom_render_autoform(@conn, :create, [{User, custom_labels: %{date_of_birth: "DOB"}, input_first: [:date_of_birth]}], assigns: [changeset: @changeset)] %>

This will now render the form with a custom label for the date_of_birth input field.

Arguments

render_autoform(conn, action, schema, options)
  • conn : Your Phoenix Plug.Conn

  • action : Either :update or :create. This will be used to create the endpoint for your form.

  • schema : Your Ecto schema

  • options : A list of options you can use to customise your forms.

    • :assigns - The assigns for the form template, for example a changeset for update forms. Will default to empty list
    • :exclude - A list of any fields in your schema you don't want to display on the form
    • :update_field - The field from your schema you want to use in your update path (/users/some-id), defaults to id
    • :assoc_query - An ecto query you want to use when loading your associations
custom_render_autoform(conn, action, [{schema, opts}], options)
  • conn : Your Phoenix Plug.Conn

  • action : Either :update or :create. This will be used to create the endpoint for your form.

  • list {schema, opts} : A list of tuples which contain your Ecto schemas and the options for the form.

    • opts include:
      • :custom_labels - A map with a key of the field from your schema and a value of text you would like to label the input with.
      • :input_first - A list of fields where you would like to display the label followed by the input.
  • options : A list of options you can use to customise your forms.

    • :assigns - The assigns for the form template, for example a changeset for update forms. Will default to empty list
    • :exclude - A list of any fields in your schema you don't want to display on the form
    • :update_field - The field from your schema you want to use in your update path (/users/some-id), defaults to id
    • :assoc_query - An ecto query you want to use when loading your associations

Associations

:many_to_many associations are rendered as checkboxes.

:belongs_to associations are rendered as a select element.

If you don't want the associations to be rendered in your form, you can add them to your exclude list (see options above).

If you are using the custom_render_autoform function and one of the schemas you pass in is an association of the changeset's schema, it will be rendered within an inputs_for call, so your changes and any errors will be correctly rendered in the form.

Fields

This module can be used in conjuction with https://github.com/dwyl/fields.

If you use one of these Fields in your schema, and that field has an input_type/0 callback. The result of that callback will be the input type that is rendered in your form.

For example, the field Fields.DescriptionPlaintextUnlimited returns :textarea from its input_type function, so autoform will render a textarea using Phoenix.HTML.Form.textarea/3

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].