Clarification on field usage and output location #784
Replies: 2 comments 2 replies
-
|
Fields are used in schemes. A scheme is the structure definition of an element.. like a page. https://getformwork.org/documentation/page-schemes/ In the website shipped with the default installation, there is a blog. You can see how a blog post is defined. See file: site\schemes\pages\post.yaml This is the structure. You can see fields like published date, tags, etc. This scheme is also extended from page scheme. So the admin UI will use both schemes to build dynamically the form in which you'll be editing the blog post entry in the admin. Then, for the front end (public website), you can see how this scheme (and fields) are used in the blog post template file here: This is basic info, but start by looking at these files. |
Beta Was this translation helpful? Give feedback.
-
|
Thank you @trancallan for reporting this, it's actually undocumented. Basically the method getFiles in the file/files field is used to retrieve the options shown in the panel, from which you can choose a file. You can override this default by specifying the dynamic field property This is the same with the image fields (in this case we have a Let's say you want to allow only png images as cover images within the post.yaml scheme, for pages with the Post template. title: Blog Post
# ...
fields:
# ...
coverImage:
type: image
label: '{{page.image}}'
options@: page.images.filterBy('extension', 'png')
# ...Basically with the syntax Then in the panel, if you upload images of different types to the page, you'll find only the pngs in the Cover image field. In a similar fashion, you could tell Formwork to take images from the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I’m trying to understand how to properly use fields in the system. I’ve read the documentation, but I’m still unsure about:
Are fields meant to be used in the admin panel, within pages, or elsewhere?
Also, I came across the following method:
$files->getFiles(): Formwork\Files\FileCollection
It seems to return a list of files associated with the field, but I’m not sure where this list is actually displayed or how it’s meant to be used in practice.
Any clarification or examples would be greatly appreciated!
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions