Skip to content

Controlled forms and inputs should always have a value #16

Description

@jho406

When using the controlled options

  form_props(controlled: true, model: Post.new) do |f|
    f.text :title
  end

The output does not contain a value

      "inputs": {
        "title": {
          "type": "text",
          "name": "post[title]",
          "id": "post_title"
        },

This poses a problem in react land because if there suddenly is a value, react will say something to the effect of "uncontrolled component suddenly becomes controlled". So if controlled is used anywhere, we should give it a default value of nil or maybe empty "". I'm not sure which one makes the most sense, and would love some opinions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions