Voyager: Defining the output view of a custom form field

Created on 19 Mar 2018  Â·  10Comments  Â·  Source: the-control-group/voyager

  • Laravel Version: 5.5.39
  • Voyager Version: 1.0.16
  • PHP Version: 7.0.28
  • Database Driver & Version: mysql, MariaDB 10.0.34

Description:

It seems there is no way apart from overriding the views/bread/read.blade.php template to define the view/HTML for custom form fields.

Even if I create the form field handler and the view as instructed on https://voyager.readme.io/v1.0/docs/adding-custom-formfields, that view is still not used when I browse a table containing the custom field, or view its records.

It looks like views/bread/read.blade.php has all the HTML output hard-coded, and any non-original field types are just output as text

Steps To Reproduce:

  • Create a custom form field as instructed in Voyager docs, modifying the template in some way (say, adding class="form-control special-type-of-numbers");
  • create BREAD for a table assigning that type to some column;
  • open that table in admin – the modification/class is not there;
  • click on "View" for some row – the modification/class is not there;
enhancement

Most helpful comment

Which is already in the making ;)

All 10 comments

Yes, that is because a Formfield is an input, not an output for read

Yes, that makes sense. Still, viewing is very closely related to editing and the whole entity management (R in CRUD, R and B in BREAD), so being able to customise the view along with customising the edit form and saving is quite important.

This would be a feature suggestion then.

Which is already in the making ;)

It should also be added that the docs don't mention this necessary step in https://docs.laravelvoyager.com/customization/adding-custom-formfields and that the docs should probably be updated to inform people of this sooner rather than later.

Was this implemented ? @emptynick docs doesnt works.

Well yes, 2 years ago round about

@emptynick and theres any docs on how to do it anywhere ?

Current adding custom formfields docs talks about the same stuff and theres no news about replacing the output on read.blades

@emptynick in your commit here:
https://github.com/the-control-group/voyager/commit/ed8cd38bdc78a8669150b7903116cd01ae827965

You have added that "/customization/overriding-formfields" doc, and it is not online anywhere so wondering if thats the way to go or what.

I have tried to add "view" to options but with no results, scraped code to figure out how it should work but the "$row->details->view" in the read.blade seems coming from Bread conf not the customformfield class.

I need to replace all views on all read.blades for a customformfield.

Could you help please with a clear example on how to make this work?

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

winex01 picture winex01  Â·  3Comments

vaggelis2018 picture vaggelis2018  Â·  3Comments

MikadoInfo picture MikadoInfo  Â·  3Comments

abacram picture abacram  Â·  3Comments

iwasherefirst2 picture iwasherefirst2  Â·  3Comments