Consider a default Frappe docType. The layout on screen of the data is not changeable. I…
- User
Consider a default Frappe docType. The layout on screen of the data is not changeable. I would like to add an extra layer, so I can drag and drop the layout of a docType.
- Assistant
To customize the layout of a Frappe DocType and make it draggable and droppable, you'll need to create a custom web form or modify the existing DocType's form view. Frappe's default DocType layout is not directly changeable, but you can create a custom app and override the default form view.
Here's a step-by-step guide to achieve this:
- Create a custom Frappe app:
If you haven't already, create a custom Frappe app using the following command in your Frappe bench:
code$ bench new-app custom_appReplace
custom_appwith the desired name for your app.- Override the DocType:
In your custom app, create a new folder named
public(if it doesn't exist) and inside it, create another folder namedwww. Inside thewwwfolder, create a new folder with the same name as the DocType you want to customize. For example, if you want to customize theItemDocType, create a folder namedItem.- Create a custom form view:
Inside the DocType folder (e.g.,
Item), create a new file namedform.html. This file will contain the custom form view for the DocType. You can use HTML, CSS, and JavaScript to create a draggable and droppable layout.Here's an example of a simple draggable and droppable form using jQuery UI:
html<div class="form-section"> <div class="row"> <div class="col-md-6" id="draggable1"> <div class="form-group"> <label>Field 1</label> {{ doc.field_1 }} </div> </div> <div class="col-md-6" id="draggable2"> <div class="form-group"> <label>Field 2</label> {{ doc.field_2 }} </div> </div> </div> </div> <script> $(function() { $("#draggable1, #draggable2").draggable({ containment: ".form-section", cursor: "move" }); }); </script>Replace
field_1andfield_2with the actual field names from your DocType.- Include jQuery UI:
To use jQuery UI, you'll need to include its CSS and JavaScript files in your custom app. You can download them from the official website () and place them in the folder of your custom app. Then, include them in your file:
- User
Is there an approach where placeholder objects are used, to achieve true drag and drop functionality and user friendliness?
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.