statamic / ideas

đź’ˇDiscussions on ideas and feature requests for Statamic
https://statamic.dev
30 stars 1 forks source link

Make BlueprintBuilder accessible like PublishForm #1106

Open maurice-ellis opened 5 months ago

maurice-ellis commented 5 months ago

I'm surprised that this isn't possible already, but as a new developer on Statamic, I find myself wanting to use the Blueprint Builder in some of my addons and field types in order to stay within the ecosystem and let's face it, Blueprints make forms a breeze. I didn't see anyone request this feature.

It would be great if BlueprintBuilder, Tabs, Fields, Field along with its other components were accessible like PublishForm,PublishContainer, etc. Additionally, to be able to have a Blueprint Builder fieldtype where I have the option to have tabs, or just have fields. I can't imagine I'm the only one that will have use for this.

For a use case, I'm building something like Bard, but solely for my front end components, so create an addon to help facilitate this. In Bard, there is sets, where I got the idea to be able to add component properties using the Blueprint Builder. unfortunately, the amount of work to get the data from Bard in GraphQL is a pain having to write fragments for everything and API doesn't provide the type of the component.

duncanmcclean commented 5 months ago

I don't think it's exactly what you're asking for but there's an open PR (https://github.com/statamic/cms/pull/8516) which will allow for addons to register their own blueprints which can be managed in the Control Panel, like any other blueprint.

Would that work for your use case?

maurice-ellis commented 5 months ago

@duncanmcclean, no this is different. This would be making the components that facilitate building blueprints public and accessible in addons. I already create blueprints in my addons programmatically, but would like GuI to facilitate it so I can manage it in the control panel instead of manually through code.

caseydwyer commented 5 months ago

Additionally, to be able to have a Blueprint Builder fieldtype where I have the option to have tabs, or just have fields.

Not entirely sure this is relevant, but you might try tinkering with the (undocumented, to my knowledge) Fields fieldtype. Eg, something like this in a blueprint...

fields:
  -
    handle: custom_field_blueprint
      field:
        type: fields
...

...will essentially give you a nested blueprint, that makes custom form-building (like below) available in the CP, which works nicely when storing in a JSON column:

image

Worth emphasizing that this is undocumented and I don't know that it's really intended to be used this way—the Link Existing button/functionality, for example, is broken. I haven't tried this, but you might also be able to use the underlying <fields> in a custom Vue component.

Hope that helps!

maurice-ellis commented 5 months ago

@caseydwyer what! I just spent a day building one and this was here the whole time? My existing link seems to work, I just needed to add a Fieldset.

This is exactly what I needed, and there needs to be documentation. I tried looking for a class under the Fieldtypes, but couldn't find anything other than Fields Display, but the class is NestedFields.

It would be nice to be able to add tabs and sections, but at least have this fieldtype added to the documentation.

Thank you Casey.

caseydwyer commented 5 months ago

Ahh, nuts—sorry I didn't see this sooner! Haha

I actually had done the same thing/similar to what you're talking about, and thought about rolling it up into an addon, but had assumed it wasn't something others would need/want. It works with sections and could pretty easily be made to work with tabs (just didn't need those for my project). Let me know if you're interested in that code and I can drop a gist in here.

maurice-ellis commented 5 months ago

Yes, it's needed, but there was nothing you could do because I posted this after I created the fieldtype. Blueprints are such a breeze, so I tried to use them as much as possible went creating something new.

I believe Statamic needs to document this field type and create a fieldtype that does Tabs and Sections. I have one of those as well, but the issue I'm concerned about is keeping up with changes and believe it would be easier of Statamic manage them and added it to the core.