Hi there - having a bit trouble disabling the Dropzone functionality and replace it with another one (since Dropzone seems not to allow modifying the preview template. Its somehow baked in to your form.min.js).
Anyway I was trying to get rid of the functionality by stripping down the file.html.twig to only allow basic multiple files (see example below).
{% set defaults = config.plugins.form %}
{% set files = defaults.files|merge(field|default([])) %}
{% set limit = not field.multiple ? 1 : files.limit %}
{% block input %}
{% set page_can_upload = exists or (type == 'page' and not exists and not (field.destination starts with '@self' or field.destination starts with 'self@')) %}
{% set settings = {name: field.name, paramName: (scope ~ field.name)|fieldName ~ (files.multiple ? '[]' : ''), limit: limit, filesize: files.filesize, accept: files.accept} %}
<div class="form-input-wrapper files-upload form-input-file {{ field.size }}" data-grav-file-settings="{{ settings|json_encode|e('html_attr') }}">
<input
{# required attribute structures #}
{% block input_attributes %}
type="file"
name="{{ (scope ~ field.name)|fieldName ~ (files.multiple ? '[]' : '') }}"
{% if files.multiple %}multiple="multiple"{% endif %}
{% if files.accept %}accept="{{ files.accept|join(',') }}"{% endif %}
{% if field.disabled %}disabled="disabled"{% endif %}
{% if field.random_name %}random="true"{% endif %}
{{ parent() }}
{% endblock %}
/>
</div>
{% endblock %}
However when I try to access the data now (with my own plugin), it seems that the files are not processed by the form plugin anymore. I can get their values by accessing $_FILES directly but than I miss all the validation and message stuff provided by the form plugin. It somehow does not get included into the data array which seems to hold all formular data. Can you please pinch me in the right direction how to solve this problem?
Here is a little code snippet:
<?php
namespace Grav\Plugin;
use Grav\Common\Data\Data;
use Grav\Common\Grav;
use Grav\Common\Plugin;
use Grav\Common\Uri;
use Grav\Common\Utils;
use RocketTheme\Toolbox\Event\Event;
class MyPlugin extends Plugin{
public static function getSubscribedEvents() {
return [
'onPluginsInitialized' => ['onPluginsInitialized', 0]
];
}
public function onPluginsInitialized()
{
if ($this->isAdmin()) {
$this->active = false;
return;
}
$this->myplugin_config = (array) $this->config->get('plugins.myplugin');
$this->enable([
'onFormProcessed' => ['onFormProcessed', 0]
]);
}
public function onFormProcessed(Event $event){
$form = $event['form'];
$action = $event['action'];
$params = $event['params'];
if (!$this->active) {
return;
}
switch ($action) {
case 'myaction':
if(isset($_POST)) {
$data = array();
$domain = 'somedomain.com';
$domain_host = $this->myplugin_config['host'];
$upload_folder = $this->myplugin_config['upload_folder'];
$formdata = $form->value()->toArray();
dump($formdata) // gives me everything but not the files
Thanks in advance for your help.