discourse/app/assets/stylesheets/common/form-kit
Joffrey JAFFEUX f6a4de4805
DEV: adds support for nested collections and objects (#30265)
Collections were an existing concept in FormKit but didn't allow nesting. You can now do infinite nesting:

```gjs
<Form
  @data={{hash
    foo=(array
      (hash bar=(array (hash baz=1))) (hash bar=(array (hash baz=2)))
    )
  }}
  as |form|
>
  <form.Collection @name="foo" as |parent parentIndex|>
    <parent.Collection @name="bar" as |child childIndex|>
      <child.Field @name="baz" @title="Baz" as |field|>
        <field.Input />
      </child.Field>
    </parent.Collection>
  </form.Collection>
</Form>
```

On top of this a new component has been added: `Object`. It allows you to represent objects in your form data. Collections are basically handling arrays, and Objects are objects.

This is useful if you form data has this shape for example:

```javascript
{ foo: { bar: 1, baz: 2 } }
```

This can now be mapped in your form using this syntax:

```gjs
<Form @data={{hash foo=(hash bar=1 baz=2)}} as |form|>
  <form.Object @name="foo" as |object name|>
    <object.Field @name={{name}} @title={{name}} as |field|>
      <field.Input />
    </object.Field>
  </form.Object>
</Form>
```

Objects accept nested collections and nested objects. Just like Collections.

A small addition has also been made to `Collection`, they now support a custom `@tagName`, it's useful if each item of your collection is the row of a table for example.
2024-12-13 15:43:32 +01:00
..
_alert.scss UX: move admin flag form to form-kit (#28187) 2024-08-05 11:01:25 +10:00
_char-counter.scss
_checkbox-group.scss DEV: Convert admin user fields to FormKit (#29070) 2024-10-14 13:19:53 +08:00
_col.scss
_collection.scss DEV: adds support for nested collections and objects (#30265) 2024-12-13 15:43:32 +01:00
_conditional-display.scss
_container.scss DEV: Migrate about config area to Form Kit (#28021) 2024-07-25 19:07:38 +03:00
_control-checkbox.scss UX: move admin flag form to form-kit (#28187) 2024-08-05 11:01:25 +10:00
_control-code.scss FIX: correctly render ace editor in FormKit (#28601) 2024-08-28 16:24:44 +02:00
_control-composer.scss
_control-custom-value-list.scss DEV: Convert admin user fields to FormKit (#29070) 2024-10-14 13:19:53 +08:00
_control-custom.scss DEV: Migrate about config area to Form Kit (#28021) 2024-07-25 19:07:38 +03:00
_control-icon.scss DEV: Convert group SMTP settings form to FormKit (#27965) 2024-07-24 09:52:52 +10:00
_control-image.scss
_control-input-group.scss
_control-input.scss DEV: <DSelect /> (#30224) 2024-12-13 10:40:06 +01:00
_control-menu.scss UX: DMenu list buttons default styling (#29250) 2024-10-21 05:05:38 +02:00
_control-password.scss DEV: Convert group SMTP settings form to FormKit (#27965) 2024-07-24 09:52:52 +10:00
_control-radio.scss UX: move admin flag form to form-kit (#28187) 2024-08-05 11:01:25 +10:00
_control-select.scss DEV: <DSelect /> (#30224) 2024-12-13 10:40:06 +01:00
_control-textarea.scss UX: fix textarea height on mobile (#28495) 2024-08-22 16:31:48 -04:00
_default-input-mixin.scss DEV: <DSelect /> (#30224) 2024-12-13 10:40:06 +01:00
_errors-summary.scss DEV: remap all core icons for fontawesome 6 upgrade (#28715) 2024-09-13 16:50:52 +01:00
_errors.scss
_field.scss FIX: applies full class to field (#29190) 2024-10-15 10:24:39 +09:00
_fieldset.scss UX: move admin flag form to form-kit (#28187) 2024-08-05 11:01:25 +10:00
_form-kit.scss
_index.scss DEV: adds support for nested collections and objects (#30265) 2024-12-13 15:43:32 +01:00
_meta.scss
_object.scss DEV: adds support for nested collections and objects (#30265) 2024-12-13 15:43:32 +01:00
_row.scss
_section.scss
_variables.scss