Repeater Field Type: How to change input view
Created 6 years ago by william

Anomaly\RepeaterFieldType\RepeaterFieldType has $inputView that i would like to change into a custom one. How do i change this for a specific repeater?

william  —  6 years ago

I might as well ask how to change the wrapper view as well. Because i tried to add Support/RepeaterFieldType/FormBuilder and define it within $options. But it doesn't look like it is automatically picked up.

william  —  6 years ago

Ive read the hooks docs and the practical example you provided in the blog. I am not sure , but i just can't get this to work. Guess ill just give up on this idea to have a custom repeater form view.

william  —  6 years ago

Code me an example and invoice me @ryanthompson 😄

ryanthompson  —  6 years ago

Try just defining it on your model in question (related config on the field) - this way it won't hit the hook defined in the repeater FT. This would be considered explicit definition of the hook handler. I think adding your own hook pry didn't work cause it fired first / the core one last and you ended up "not overriding anything".. this is more explicitly forced into the FT.

public function newRepeaterFieldTypeFormBuilder() {
    return app(MyCustomRepeaterFormBuilder::class)
}

You can also make your own form builder AS LONG AS you've bound your entry model properly (so it's located within your addon): https://github.com/anomalylabs/repeater-field_type/blob/1.3/src/RepeaterFieldTypeServiceProvider.php#L57 This would be considered auto-detection.

<?php namespace Example\CatsModule\Cat\Support\RepeaterFieldType;

class FormBuilder extends \Anomaly\Streams\Platform\Ui\Form\FormBuilder
{
    // Normal form builder stuff
}

Note that unlike the table builders it doesn't have to extend anything in particular.