https://github.com/jonathandey/oc-jd-form
An OctoberCMS plugin that enables you to use backend forms on the front-end
https://github.com/jonathandey/oc-jd-form
form form-builder octobercms octobercms-plugin
Last synced: about 2 months ago
JSON representation
An OctoberCMS plugin that enables you to use backend forms on the front-end
- Host: GitHub
- URL: https://github.com/jonathandey/oc-jd-form
- Owner: jonathandey
- License: mit
- Created: 2020-11-29T19:26:24.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-11-29T19:37:49.000Z (over 4 years ago)
- Last Synced: 2025-04-06T03:06:35.006Z (2 months ago)
- Topics: form, form-builder, octobercms, octobercms-plugin
- Language: PHP
- Homepage:
- Size: 6.84 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JD Form
An OctoberCMS plugin that enables you to use backend forms on the front-end.
This enables fast bootstrapping, form maintenance & helps prevent duplicate code.
## Example usage
```
title = "Form Demonstration"
url = "/form/:context/:id?"
layout = "default"[jdForm]
model_id = "{{ :id }}"
form_context = "{{ :context }}"
model_class = "Author\Plugin\Models\Model"
==
{% component 'jdForm' %}```
Then visit;
* https://mysite.example/form/create to create a new model record.
* https://mysite.example/form/update/1 to update a models record.## Fields definition
You can define fields definition using the `definition` parameter for the `jdForm` component.By default the plugin will look for a front-end fields file. It will look for a file called `fields_frontend.yaml` inside your models directory.
Otherwise it will use your `fields.yaml` file, the same one that is used on the backend.## Including the functionality in your own component
You can add the JD Form component to your own component using the addComponent method
```
$this->controller->addComponent("jdForm", "jdForm", [
"model_id" => 1,
"form_context" => "update",
"model_class" => "Author\Plugin\Models\Model"
])
```## Override form field templates (untested)
_Borrowed from https://octobercms.com/plugin/luketowers-easyforms_You can easily override any backend partial that would be rendered by the form & it's included widgets by replicating the desired partial under the `themes/$activeTheme/partials/$componentAlias` directory. If a match isn't found in that directory it will fall back by looking at the `themes/$activeTheme/partials/jdForm` directory.
In order for a given partial to be overridden, it must be copied under the above directory using the exact same (case-sensitive) application root relative path as where it exists normally. For instance, if you wanted to override the `/path/to/october/modules/backend/widgets/form/partials/_field_text.htm` partial, then you would need to create a file under `/path/to/october/themes/$activeTheme/partials/$widgetAlias/modules/backend/widgets/form/partials/_field_text.htm`.