WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.33k stars 4.12k forks source link

DataViews: Forms #59745

Open youknowriad opened 6 months ago

youknowriad commented 6 months ago

Problem scope

As we continue expanding our UIs, be it the editor UI or new pages being added to the site editor, we’re finding our selves creating a lot of forms to edit entities and for each one of these, we keep recreating adhoc designs and implement adhoc forms.

Here are some of the existing forms:

Screenshot 2024-03-11 at 9 58 55 AM Screenshot 2024-03-07 at 4 14 39 PM

Also, as we advance into the admin redesign work, we’ll be creating even more forms:

To avoid, creating and designing UIs for these over and over again in an adhoc and inconsistent way, we should explore an API to generate these forms consistently.

Proposal

When implementing the DataViews in the site editor, we introduce a “fields” config for each data view component. To render a DataView, we’ve built a generic component with the following API:

<DataViews data={data} fields={ fields } view={ view } />

So this component render a list of items given a “fields” config and a some options (view).

Similarly, we should explore building a generic component that renders a form/panel

<DataForm item={item} fields={ fields } form={ form } />

Such component would render a form or panel for a given item based on a “fields” config and some options (form).

Notes

Log

WordPress 6.7

joshuatf commented 2 months ago

@youknowriad @oandregal Out of curiosity, will the DataForm ever allow control over layout within a form (columns, tabs, sections, etc) or would those be comprised of multiple DataForms?

youknowriad commented 2 months ago

@joshuatf My current thinking is that "columns" and "tabs" are something you should be able to control on the form object. It's not clear to me at this point if a single "form type" can absorb everything or if we'd need several "form layouts" or "form types" like we have for data views, but I think we should be able do say, I want to group these fields in a tab...

jameskoster commented 1 month ago

Noting this is closely related to https://github.com/WordPress/gutenberg/issues/63624.

oandregal commented 1 month ago

Added a new section in the issue for "Task/Log".

Also: created https://github.com/WordPress/gutenberg/pull/63895 that prepares the initial structure for validation.

oandregal commented 1 month ago

https://github.com/WordPress/gutenberg/pull/63983 adds the ability to update the author in the quick edit form.

oandregal commented 1 month ago

In https://github.com/WordPress/gutenberg/pull/63983 I ran into some issues with sorting. While working on them we discussed the need to formalize a bit the existing field types. This is the ongoing work: