Bard output not converted to a Statamic Sets/collection. #634
-
DescriptionHI! I am working on integrating Runway in a Statamic application within a specific (Laravel) Blade view, returned by a regular controller. The field in question, pdp_content, is a Bard field stored as JSON. When dumped into the Blade view, the data is converted from JSON into a PHP array using the model's casts attribute:
However, I need the data structured in a way that mimics a regular Bard field's sets. This would allow me to reuse existing field sets without altering the current HTML structure. Steps to reproduce
What i tried
Expected BehaviourThe array output of the Bard field (pdp_content) should be structured as a Bard set collection, matching the behavior of Statamic's native Bard fields. QuestionIs there a way to convert a regular PHP array (from the pdp_content field) into a Bard set collection? This would allow me to seamlessly integrate with existing Bard field sets in Statamic without modifying the underlying HTML. This is for a project where I’m leveraging Statamic Runway and integrating it into a Laravel Blade view. The goal is to maintain consistency with existing Bard field data structures. Thank you for your help! EnvironmentEnvironment Cache Drivers Locales Filament Livewire Statamic Statamic Addons |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hmm, there's isn't anything in Statamic or Runway for that. You'd need to write a command that goes through your array, maps them to the Bard structure, then updates the Alternatively, you could maybe write some kind of accessor/mutator to handle it. |
Beta Was this translation helpful? Give feedback.
Hi Duncan,
I've looked into this with my colleague. He found a solution by iterating over the data like this:
and casting the data to an array via the model.