Authors: Bob den Otter, Ivo Valchev
This Bolt extension can be used to handle forms in your Bolt 4/5 project.
Installation:
composer require bolt/forms
The full documentation for this extension can be found here: BoltForms documentation.
License: MIT License
Authors: Bob den Otter, Ivo Valchev
This Bolt extension can be used to handle forms in your Bolt 4/5 project.
Installation:
composer require bolt/forms
The full documentation for this extension can be found here: BoltForms documentation.
bolt 4.1 + bolt/forms
When submitting a form it will crash with the error: An exception has been thrown during the rendering of a template ("Notice: Trying to access array offset on value of type null").
When dumping the config var in vendor/bolt/forms/src/factory/EmailFactory.php
at line 29 like so
dd($config->get('debug'));
$debug = (bool) $config->get('debug')['enabled'];
an error is triggered because the config is null
Working with bolt 5 beta 10.
The uploads: settings seems to be ignored entirely and files are uploaded to /uploads/ by default even if enabled is explicitly set to false. As far as I've been able to tell, all child keys are ignored.
filename_handling: "suffix" is also ignored. defaults to prefix.
I have no clue if management_controller works as expected, but I've set it to false.
the attach_files: true key is also ignored.
At this point file type fields cannot safely be used.
My result: emails submit without attachments and my uploads folder is flooded with files.
https://bolt.github.io/forms/captcha.html
could use an update with the info from here:
https://github.com/bolt/forms/blob/8149c9082422d9208c5ba57045599d3788ab7f9a/docs/captcha.md
I found this because pages with forms were throwing exceptions about non existing indexes
Hello !
I want to add event listener on pre_submit (for add data before submit) in a form.
I try to listen BoltFormsEvents::PRE_SUBMIT or boltforms.pre_submit (same) but when I try setData from Bolt\BoltForms\Event, I got an error :
An exception has been thrown during the rendering of a template ("Bolt\BoltForms\Event\BoltFormsEvent::setData can only be called in BoltFormsEvents::PRE_SUBMIT")
I thinks the problem is vendor/bolt/forms/src/Event/BoltFormsEvent.php (l.65)
if ($this->formsEventName === FormEvents::PRE_SUBMIT) {
$this->event->setData($data);
} else {
throw new \RuntimeException(self::class . '::' . __FUNCTION__ . ' can only be called in BoltFormsEvents::PRE_SUBMIT');
}
$this->formsEventName
send BoltFormsEvents::PRE_SUBMIT but condition allow only FormEvents::PRE_SUBMIT
Can you check that or tell me if I'm wrong :-)
(I can make a pull request if you want)
Just upgraded to 1.0.8
When I submit the form I get
Can't set Field 'attachments' of 'enquiries'. Make sure the Field is defined in the Enquiries ContentType. - but I don't have a field called "attachments" in the form.
Then if I create attachments on my content type, I resubmit again, I get
Can't set Field 'type_type_twitter' of 'enquiries'. Make sure the Field is defined in the Enquiries ContentType.
I think this is the honeypot field - what config am I missing so that this does not get added to the contenttype?
Thanks
I need to get some form of CAPTCHA on my site's contact form (which uses this extension) and whilst I can see the options are there in the config file (and I've enabled them) they don't seem to work.
Is this implemented in the Bolt 4 version of this extension, as I cannot see any code relating to it?
If it isn't, I'm happy to write this and submit a PR to implement both reCAPTCHA and hCaptcha - I just wanted to confirm before I do as I didn't want to duplicate any effort.
I have cloned a project that I hadn't worked on for quite some time to a different machine, I ran composer install and update, and copied over the SQLite database and some assets from the other machine. On the new machine I was getting this error:
An exception has been thrown during the rendering of a template ("The "C:/tools/xampp/vhosts/sitename/config/extensions\bolt-boltforms" directory does not exist.").
The issue seems pretty straightforward, but I got fixated on some wrong initial thoughts. How can a directory be missing, I have committed everything? And why is it looking for a directory, only config files are supposed to be there? Is it looking for the config file of the same name, but it's not working because it's using both forward and back slashes in the path for some reason?
Well, after wasting an embarrassing amount of time, I have figured out that there is actually supposed to be a directory like that in there, but Git didn't commit it because it was empty and Composer didn't create it even though I had tried doing a bunch of stuff with it.
The goof is mine, but I believe there should be a safeguard implemented against situations like this and it should be pretty easy.
Options:
Using Bolt 4, I want to be able to get the path of an uploaded file and store it in a contenttype but could'nt find how.
$event->getAttachments()
was always empty and $form->getData()
show me original file in tmp and without suffix.
I dig a bit in extension code and config option and have some questions
in bolt-boltforms.yaml you can set options for uploads:
uploads:
enabled: true # The global on/off switch for upload handling
base_directory: /home/[user]/[foo]/uploads # Outside web root and writable by the web server's
filename_handling: suffix # Can be either "prefix", "suffix", or "keep"
management_controller: true # Enable a controller to handle browsing and downloading of uploaded files
An uploads
folder is created in bolt root project and files are uploaded in it, ignoring your base_directory
option.
If you set a subdirectory
option in your form config, it is ignored too
there is no controller in extension so.... management_controller
option does something ?
my_form:
uploads:
subdirectory: candidatures # Optional subdirectory
in src/EventSubscriber/FileUploadHandler.php, you find no use of base_directory option or subdirectory.
// src/EventSubscriber/FileUploadHandler.php
private function processFileField(Form $field, Collection $fieldConfig, PostSubmitEvent $event): void
{
$file = $field->getData();
$form = $event->getForm();
$formConfig = $event->getFormConfig();
$filename = $this->getFilename($field->getName(), $form, $formConfig);
$path = $fieldConfig['directory'] ?? '/uploads/';
Str::ensureStartsWith($path, \DIRECTORY_SEPARATOR);
$files = $this->uploadFiles($filename, $file, $path);
if (isset($fieldConfig['attach']) && $fieldConfig['attach']) {
$event->addAttachments([$field->getName() => $files]);
}
}
In this function we see $fieldConfig is used with directory
and attach
key
So if i put those key in my formfield config
f_avatar_upload:
type: file
directory: /uploads/avatar/ #add
attach: true # add
options:
required: false
label: Image représentant le personnage
constraints:
- Image:
mimeTypes: [ 'image/png', 'image/jpeg' ]
mimeTypesMessage: 'Le document doit être au format png ou jpg'
help: "Cette information sera visible par tous"
Boom, my file is uploaded in the subdirectory , i finaly see attachement in $event->getAttachments()
and it's sort of what i needed... filepath with suffix
array:5 [▼
"ip" => "127.0.0.1"
"timestamp" => Carbon\Carbon @1625135286 {#4318 ▶}
"path" => "/inscription/creation-de-son-personnage?code=ij6HYzYGYKDRQlTJyMdDp0JfejxoBY"
"url" => "http://127.0.0.1:8000/inscription/creation-de-son-personnage?code=ij6HYzYGYKDRQlTJyMdDp0JfejxoBY"
"attachments" => array:1 [▼
"f_avatar_upload" => array:1 [▼
0 => "/home/[user]/[foo]/[bla]/[my_bolt_project]/uploads/avatar/75a4a196_Uploaded file60dd98b6bded220190212223454-1.jpg"
]
]
]
Maybe i missed something but if it's the way it means to work, a bit of documentation can be added to config.yaml in the file example
# upload:
# type: file
# attach: true # attach your file if you need to send it or save it
# directory: /uploads/pet/ #path to directory where file is uploaded
# options:
# required: false
# label: Picture of your pet that you want us to add to our site
edit: Add management_controller in first question.
Are you plan to support for original symfony/form events as in previous boltforms (bolt3 addon)?
If yes, I've clone and adapt this functionality from previous boltforms addon. It helped me to integrate 3d party recapture3 bundle by adding recapture3 type on PRE_SET_DATA symfony/form event, so form starts to work like a charm
GDPR considers IP personal data.
Option to disable collection of IP as submitted form value.
We shouldn't include bootstrap like, always, in the form.html.twig
template
Or, if we should, at least provide an option to override it without overriding the template itself.
I've just updated my dev site to 1.1.1 to implement my CAPTCHA work in my own site, and noticed my honeypot field was always visible.
There is a Javascript error in the browser console stating it cannot find a particular field:
Uncaught TypeError: can't access property "style", el is null
This is in the Honeypot Javascript:
The funny thing is this field doesn't actually exist - the Honeypot field is called something totally different.
I was looking through the commits in 1.1.1 to work out what had changed (as I didn't see this in my development of the CAPTCHA work) and found a change that ECS has made in src/Honeypot.php.
It looks like it has replaced mt_rand
with random_int
- luckily the comment explicitly states why you are using mt_rand
!!
Reverting this change fixes my Honeypot field.
Bolt Forms 1.4.17
I'm using the reCaptcha v3 field type and need to specify the Google API keys. Currently it seems that you cannot use any Symfony configuration parameters or environment variables in this config file, like you can with Symfony YAML configuration, so I'm forced to hard-code the API keys, meaning they get stored in the Git repo and are visible to all.
Is this a known limitation?
Thanks
It doesn't matter if the option is set or not - the page reloads.
Hi all
Here's a suggested configuration for a future major release of bolt/forms
. Please provide any feedback that you may have!
## This is default, all forms inherit from here.
default:
csrf: true
honeypot: true
spam-action: mark-as-spam
template: '@boltforms/form.html.twig'
layout: 'form_div_layout.html.twig'
captcha:
repatcha: ...
hcaptcha: ...
contact:
csrf: false # here you can override any of the default config
attr: ?? # Add attributes to form itself?
content:
step: 1
fields: ... # Same as current form
on_submit:
save:
contenttype:
name: ..
field_map: ...
table:
name: ...
field_map: ...
email: # the email is a list, allowing you to send as many emails to as many recipients as you like
- subject_template: ...
body_template: ...
recipients: [ [email protected], {FROM_FIELD} ]
cc_recipients: ...
bcc_recipients: ...
attach: [ name of file fields to attach ]
action:
redirect: ...
messages:
success: ...
error: ...
I've configured a form to the database table "mailing" but it doesn't receive any input, even if the form itself plays back a success message:
## Subscribe subscribe: templates: form: 'partials/_subscribe.twig' feedback: success: Deine E-Mail Adresse email wurden erfolgreich eingetragen. error: Die eingegebene E-Mail Adresse ist ungültig. database: table: name: mailing field_map: mail: 'mail' timestamp: 'lastseen_at' url: ~ path: ~ ip: 'last_ip'
It's about submitting the date in the form.
It turns out this is not possible as in
Bolt\BoltForms\EventSubscriber\ContentTypePersister::setContentFields
this line $value = (string) $value;
throws the exception Object of class DateTime could not be converted to string
What I have tried so far is
$value = $value;
} else {
$value = (string) $value;
}``
Knowing fully well that this is just a little hack, it works but unfortunately it takes 30+ seconds to persist and ends with a 500 server fault.
If bolt-boltforms.yaml template block is configured as:
templates:
form: 'extensions/boltforms/form.html.twig'
email: 'extensions/boltforms/email.html.twig'
subject: 'extensions/boltforms/subject.html.twig'
files: 'extensions/boltforms/file_browser.twig'
and a form is configured as:
## Subscribe
subscribe:
templates:
form: 'partials/_subscribe.twig'
feedback:
success: Deine E-Mail Adresse email wurden erfolgreich eingetragen.
error: Die eingegebene E-Mail Adresse ist ungültig.
fields:
email:
type: email
options:
required: true
label: E-Mail Adresse
attr:
placeholder: E-Mail Adresse
constraints: [ NotBlank, Email ]
submit:
type: submit
options:
label: Submit
attr:
class: button primary
The used template is still "form.html.twig" when it should be "_subscribe.twig" instead.
It's about submitting the date in the form.
It turns out this is not possible as in
Bolt\BoltForms\EventSubscriber\ContentTypePersister::setContentFields
this line $value = (string) $value;
throws the exception Object of class DateTime could not be converted to string
What I have tried so far is
$value = $value;
} else {
$value = (string) $value;
}``
Knowing fully well that this is just a little hack, it works but unfortunately it takes 30+ seconds to persist and ends with a 500 server fault.
It seems my patch #95 introduced an regression: ("Notice: Undefined offset: 0")
, when an uploaded file is absent in the form.
What seems to work for me is:
changeing this:
if (is_array($value)) {
$value = implode(', ', array_map(function ($entry) {
return $entry[0];
}, $value));
}
to:
if (is_array($value)) {
$value = implode(', ', array_map(function ($entry) {
if (is_array($entry) and count($entry) > 0) {
return $entry[0];
}
}, $value));
}
i move on and test on the way and if it works properly make another PR.
(in the default folder uploads/
, outside of the webroot.
hi everyone,
when I submit my contact form with a captcha type field (I have all tried it), I have the following error:
"An exception has been thrown during the rendering of a template ("Warning: in_array() expects parameter 2 to be array, null given")."
I applied exactly the configuration that there is here https://github.com/bolt/forms/blob/8149c9082422d9208c5ba57045599d3788ab7f9a/docs/captcha.md
any idea please ?
thanks
forms/src/EventSubscriber/Redirect.php
Line 66 in f3df793
request.CRITICAL: Uncaught PHP Exception Symfony\Component\ErrorHandler\Error\ClassNotFoundError: "Attempted to load class "HttpException" from namespace "Bolt\BoltForms\EventSubscriber". Did you forget a "use" statement for e.g. "Symfony\Component\HttpKernel\Exception\HttpException" or "SensioLabs\Security\Exception\HttpException"?" at ./vendor/bolt/forms/src/EventSubscriber/Redirect.php line 75 {"exception":"[object] (Symfony\Component\ErrorHandler\Error\ClassNotFoundError(code: 0): Attempted to load class "HttpException" from namespace "Bolt\BoltForms\EventSubscriber".\nDid you forget a "use" statement for e.g. "Symfony\Component\HttpKernel\Exception\HttpException" or "SensioLabs\Security\Exception\HttpException"? at ./vendor/bolt/forms/src/EventSubscriber/Redirect.php:75)"} []
I need preinitialise some value into form.
Hi,
I get this error when trying to submit form with a file:
"Serialization of 'Symfony\Component\HttpFoundation\File\UploadedFile' is not allowed"
From what I found unsetting file fields on EmailFactory
level from form data passed to context ( files are preserved in attachements ) works fine
Stacktrace:
Serialization of 'Symfony\Component\HttpFoundation\File\UploadedFile' is not allowed
at vendor/symfony/twig-bridge/Mime/BodyRenderer.php:52
at serialize(array(array('data' => array('name' => 'Name', 'email' => '[email protected]', 'phone' => '0', 'upload' => object(UploadedFile), 'message' => 'This is a test', 'string_city_processor_string' => null), 'formname' => 'vacature', 'meta' => array('ip' => '172.18.0.13', 'timestamp' => object(Carbon), 'path' => '/vacature/online-marketing-stage', 'url' => 'http://mrwork.test/vacature/online-marketing-stage'), 'config' => object(Collection)), null, '@bolt/email/email.twig'))
(vendor/symfony/twig-bridge/Mime/BodyRenderer.php:52)
at Symfony\Bridge\Twig\Mime\BodyRenderer->render(object(TemplatedEmail))
(vendor/symfony/mailer/EventListener/MessageListener.php:125)
at Symfony\Component\Mailer\EventListener\MessageListener->renderMessage(object(TemplatedEmail))
(vendor/symfony/mailer/EventListener/MessageListener.php:72)
at Symfony\Component\Mailer\EventListener\MessageListener->onMessage(object(MessageEvent), 'Symfony\\Component\\Mailer\\Event\\MessageEvent', object(TraceableEventDispatcher))
(vendor/symfony/event-dispatcher/Debug/WrappedListener.php:117)
at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(MessageEvent), 'Symfony\\Component\\Mailer\\Event\\MessageEvent', object(TraceableEventDispatcher))
(vendor/symfony/event-dispatcher/EventDispatcher.php:230)
at Symfony\Component\EventDispatcher\EventDispatcher->callListeners(array(object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'Symfony\\Component\\Mailer\\Event\\MessageEvent', object(MessageEvent))
(vendor/symfony/event-dispatcher/EventDispatcher.php:59)
at Symfony\Component\EventDispatcher\EventDispatcher->dispatch(object(MessageEvent), 'Symfony\\Component\\Mailer\\Event\\MessageEvent')
(vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:151)
at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch(object(MessageEvent))
(vendor/symfony/mailer/Transport/AbstractTransport.php:63)
at Symfony\Component\Mailer\Transport\AbstractTransport->send(object(TemplatedEmail), object(DelayedEnvelope))
(vendor/symfony/mailer/Transport/Smtp/SmtpTransport.php:132)
at Symfony\Component\Mailer\Transport\Smtp\SmtpTransport->send(object(TemplatedEmail), null)
(vendor/symfony/mailer/Transport/Transports.php:51)
at Symfony\Component\Mailer\Transport\Transports->send(object(TemplatedEmail), null)
(vendor/symfony/mailer/Mailer.php:42)
at Symfony\Component\Mailer\Mailer->send(object(TemplatedEmail))
(vendor/bolt/forms/src/EventSubscriber/Mailer.php:53)
at Bolt\BoltForms\EventSubscriber\Mailer->mail()
(vendor/bolt/forms/src/EventSubscriber/Mailer.php:45)
at Bolt\BoltForms\EventSubscriber\Mailer->handleEvent(object(PostSubmitEvent), 'boltforms.post_submit', object(TraceableEventDispatcher))
(vendor/symfony/event-dispatcher/Debug/WrappedListener.php:117)
at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(PostSubmitEvent), 'boltforms.post_submit', object(TraceableEventDispatcher))
(vendor/symfony/event-dispatcher/EventDispatcher.php:230)
at Symfony\Component\EventDispatcher\EventDispatcher->callListeners(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'boltforms.post_submit', object(PostSubmitEvent))
(vendor/symfony/event-dispatcher/EventDispatcher.php:59)
at Symfony\Component\EventDispatcher\EventDispatcher->dispatch(object(PostSubmitEvent), 'boltforms.post_submit')
(vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:151)
at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch(object(PostSubmitEvent), 'boltforms.post_submit')
(vendor/bolt/forms/src/Event/PostSubmitEventDispatcher.php:46)
at Bolt\BoltForms\Event\PostSubmitEventDispatcher->dispatch('vacature', object(Form), object(Request))
(vendor/bolt/forms/src/Event/PostSubmitEventDispatcher.php:35)
at Bolt\BoltForms\Event\PostSubmitEventDispatcher->handle('vacature', object(Form), object(Request))
(vendor/bolt/forms/src/FormRuntime.php:76)
at Bolt\BoltForms\FormRuntime->run('vacature')
(var/cache/dev/twig/1f/1f6b4fb345504e236615f4a234554abd08466c317846fd96203cd0458bc6a5ff.php:297)
at __TwigTemplate_677ada4d956285ccc1203144f539b4a340bfcf90fb4bad463f584b3ce12e0e11->block_main(array('record' => object(Content), 'vacature' => object(Content), 'user' => null, 'theme' => object(DeepCollection), 'app' => object(AppVariable), 'config' => object(Config), 'seo' => object(Seo)), array('inlineStyle' => array(object(__TwigTemplate_cc75ee5fcab64e0f63d9ddbde3dbcdce23da5f39b15305ea70c58d655f695fd3), 'block_inlineStyle'), 'bodyId' => array(object(__TwigTemplate_677ada4d956285ccc1203144f539b4a340bfcf90fb4bad463f584b3ce12e0e11), 'block_bodyId'), 'bodyClass' => array(object(__TwigTemplate_677ada4d956285ccc1203144f539b4a340bfcf90fb4bad463f584b3ce12e0e11), 'block_bodyClass'), 'main' => array(object(__TwigTemplate_677ada4d956285ccc1203144f539b4a340bfcf90fb4bad463f584b3ce12e0e11), 'block_main'), 'inlineScripts' => array(object(__TwigTemplate_cc75ee5fcab64e0f63d9ddbde3dbcdce23da5f39b15305ea70c58d655f695fd3), 'block_inlineScripts')))
(vendor/twig/twig/src/Template.php:171)
at Twig\Template->displayBlock('main', array('record' => object(Content), 'vacature' => object(Content), 'user' => null, 'theme' => object(DeepCollection), 'app' => object(AppVariable), 'config' => object(Config), 'seo' => object(Seo)), array('inlineStyle' => array(object(__TwigTemplate_cc75ee5fcab64e0f63d9ddbde3dbcdce23da5f39b15305ea70c58d655f695fd3), 'block_inlineStyle'), 'bodyId' => array(object(__TwigTemplate_677ada4d956285ccc1203144f539b4a340bfcf90fb4bad463f584b3ce12e0e11), 'block_bodyId'), 'bodyClass' => array(object(__TwigTemplate_677ada4d956285ccc1203144f539b4a340bfcf90fb4bad463f584b3ce12e0e11), 'block_bodyClass'), 'main' => array(object(__TwigTemplate_677ada4d956285ccc1203144f539b4a340bfcf90fb4bad463f584b3ce12e0e11), 'block_main'), 'inlineScripts' => array(object(__TwigTemplate_cc75ee5fcab64e0f63d9ddbde3dbcdce23da5f39b15305ea70c58d655f695fd3), 'block_inlineScripts')))
(var/cache/dev/twig/9a/9a06aa87d58165d02443c1662ef6c73f29db45f0a6c30b38e95c3333e3844f29.php:263)
at __TwigTemplate_cc75ee5fcab64e0f63d9ddbde3dbcdce23da5f39b15305ea70c58d655f695fd3->doDisplay(array('record' => object(Content), 'vacature' => object(Content), 'user' => null, 'theme' => object(DeepCollection), 'app' => object(AppVariable), 'config' => object(Config), 'seo' => object(Seo)), array('inlineStyle' => array(object(__TwigTemplate_cc75ee5fcab64e0f63d9ddbde3dbcdce23da5f39b15305ea70c58d655f695fd3), 'block_inlineStyle'), 'bodyId' => array(object(__TwigTemplate_677ada4d956285ccc1203144f539b4a340bfcf90fb4bad463f584b3ce12e0e11), 'block_bodyId'), 'bodyClass' => array(object(__TwigTemplate_677ada4d956285ccc1203144f539b4a340bfcf90fb4bad463f584b3ce12e0e11), 'block_bodyClass'), 'main' => array(object(__TwigTemplate_677ada4d956285ccc1203144f539b4a340bfcf90fb4bad463f584b3ce12e0e11), 'block_main'), 'inlineScripts' => array(object(__TwigTemplate_cc75ee5fcab64e0f63d9ddbde3dbcdce23da5f39b15305ea70c58d655f695fd3), 'block_inlineScripts')))
(vendor/twig/twig/src/Template.php:394)
at Twig\Template->displayWithErrorHandling(array('record' => object(Content), 'vacature' => object(Content), 'user' => null, 'theme' => object(DeepCollection), 'app' => object(AppVariable), 'config' => object(Config), 'seo' => object(Seo)), array('inlineStyle' => array(object(__TwigTemplate_cc75ee5fcab64e0f63d9ddbde3dbcdce23da5f39b15305ea70c58d655f695fd3), 'block_inlineStyle'), 'bodyId' => array(object(__TwigTemplate_677ada4d956285ccc1203144f539b4a340bfcf90fb4bad463f584b3ce12e0e11), 'block_bodyId'), 'bodyClass' => array(object(__TwigTemplate_677ada4d956285ccc1203144f539b4a340bfcf90fb4bad463f584b3ce12e0e11), 'block_bodyClass'), 'main' => array(object(__TwigTemplate_677ada4d956285ccc1203144f539b4a340bfcf90fb4bad463f584b3ce12e0e11), 'block_main'), 'inlineScripts' => array(object(__TwigTemplate_cc75ee5fcab64e0f63d9ddbde3dbcdce23da5f39b15305ea70c58d655f695fd3), 'block_inlineScripts')))
(vendor/twig/twig/src/Template.php:367)
at Twig\Template->display(array('record' => object(Content), 'vacature' => object(Content), 'user' => null, 'theme' => object(DeepCollection), 'app' => object(AppVariable), 'config' => object(Config), 'seo' => object(Seo)), array('bodyId' => array(object(__TwigTemplate_677ada4d956285ccc1203144f539b4a340bfcf90fb4bad463f584b3ce12e0e11), 'block_bodyId'), 'bodyClass' => array(object(__TwigTemplate_677ada4d956285ccc1203144f539b4a340bfcf90fb4bad463f584b3ce12e0e11), 'block_bodyClass'), 'main' => array(object(__TwigTemplate_677ada4d956285ccc1203144f539b4a340bfcf90fb4bad463f584b3ce12e0e11), 'block_main')))
(var/cache/dev/twig/1f/1f6b4fb345504e236615f4a234554abd08466c317846fd96203cd0458bc6a5ff.php:50)
at __TwigTemplate_677ada4d956285ccc1203144f539b4a340bfcf90fb4bad463f584b3ce12e0e11->doDisplay(array('record' => object(Content), 'vacature' => object(Content), 'user' => null, 'theme' => object(DeepCollection), 'app' => object(AppVariable), 'config' => object(Config), 'seo' => object(Seo)), array('bodyId' => array(object(__TwigTemplate_677ada4d956285ccc1203144f539b4a340bfcf90fb4bad463f584b3ce12e0e11), 'block_bodyId'), 'bodyClass' => array(object(__TwigTemplate_677ada4d956285ccc1203144f539b4a340bfcf90fb4bad463f584b3ce12e0e11), 'block_bodyClass'), 'main' => array(object(__TwigTemplate_677ada4d956285ccc1203144f539b4a340bfcf90fb4bad463f584b3ce12e0e11), 'block_main')))
(vendor/twig/twig/src/Template.php:394)
at Twig\Template->displayWithErrorHandling(array('record' => object(Content), 'vacature' => object(Content), 'user' => null, 'theme' => object(DeepCollection), 'app' => object(AppVariable), 'config' => object(Config), 'seo' => object(Seo)), array('bodyId' => array(object(__TwigTemplate_677ada4d956285ccc1203144f539b4a340bfcf90fb4bad463f584b3ce12e0e11), 'block_bodyId'), 'bodyClass' => array(object(__TwigTemplate_677ada4d956285ccc1203144f539b4a340bfcf90fb4bad463f584b3ce12e0e11), 'block_bodyClass'), 'main' => array(object(__TwigTemplate_677ada4d956285ccc1203144f539b4a340bfcf90fb4bad463f584b3ce12e0e11), 'block_main')))
(vendor/twig/twig/src/Template.php:367)
at Twig\Template->display(array('record' => object(Content), 'vacature' => object(Content), 'user' => null, 'theme' => object(DeepCollection)))
(vendor/twig/twig/src/Template.php:379)
at Twig\Template->render(array('record' => object(Content), 'vacature' => object(Content), 'user' => null, 'theme' => object(DeepCollection)), array())
(vendor/twig/twig/src/TemplateWrapper.php:40)
at Twig\TemplateWrapper->render(array('record' => object(Content), 'vacature' => object(Content), 'user' => null, 'theme' => object(DeepCollection)))
(vendor/twig/twig/src/Environment.php:277)
at Twig\Environment->render(object(TemplateWrapper), array('record' => object(Content), 'vacature' => object(Content), 'user' => null, 'theme' => object(DeepCollection)))
(vendor/bolt/core/src/Controller/TwigAwareController.php:111)
at Bolt\Controller\TwigAwareController->render(object(TemplateWrapper), array('record' => object(Content), 'vacature' => object(Content), 'user' => null, 'theme' => object(DeepCollection)))
(vendor/bolt/core/src/Controller/TwigAwareController.php:161)
at Bolt\Controller\TwigAwareController->renderSingle(object(Content), true)
(vendor/bolt/core/src/Controller/Frontend/DetailController.php:55)
at Bolt\Controller\Frontend\DetailController->record('online-marketing-stage', 'vacature', true)
(vendor/symfony/http-kernel/HttpKernel.php:157)
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
(vendor/symfony/http-kernel/HttpKernel.php:79)
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
(vendor/symfony/http-kernel/Kernel.php:195)
at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
(public/index.php:39)
Both spam-action
settings for the honeypot are not preventing spam from being processed.
Bolt 4.1.22 composer install
PHP 7.3
Boltforms 1.4.2
csrf: true
honeypot: true
spam-action: one of ['mark-as-spam', 'block']
Fill out form with email notification and enter some text in the hidden honeypot input then submit.
Subject of email notification gets '[SPAM] ' prepended.
Email notification delivered without spam prefix in the subject.
Fill out form with email notification and enter some text in the hidden honeypot input then submit.
An extra special error occured.
is shown and email is not being sent.
An extra special error occured.
is shown additionally to what is set in feedback: error:
and the email notification is still sent.
Pretty sure multilingual forms are either already possible, or will be relatively easy to implement, using the translation bundle.
It's about submitting the date in the form.
It turns out this is not possible as in
Bolt\BoltForms\EventSubscriber\ContentTypePersister::setContentFields
this line
$value = (string) $value;
throws the exception
Object of class DateTime could not be converted to string
What I have tried so far is
if ($value instanceof DateTime) {
$value = $value;
} else {
$value = (string) $value;
}
Knowing fully well that this is just a little hack, it works but unfortunately it takes 30+ seconds to persist and ends with a 500 server fault.
Currently my functional tests on a form with reCaptcha v3 are failing - obviously the JS is not being executed, but the backend is still looking for the reCaptcha data in the POST submission.
Is there a way to sort this? I cannot find a way to override the form field configuration based on the Symfony environment - my first thought was simply to remove the reCaptcha field if the env is "test".
Any pointers on how to achieve this would be much appreciated. Thanks.
Hello. I want to make a custom form to submit a comment for an article, and not to use {{ boltform('myForm') }} in order to pass some additional fields (author, articleId) that point to record relations.
I have the following code:
bolt-boltforms.yaml
commentForm:
submission:
ajax: false # Use AJAX for form submission and handling
notification:
enabled: false
debug: false
debug_address: [email protected] # Email address used when debug mode is enabled
debug_smtp: true
subject: "[TESTING] A showcase form was just submitted"
from_name: name # A field name, specified in the fields: section below
replyto_email: email # A field name, specified in the fields: section below
replyto_name: name # A field name, specified in the fields: section below
from_email: email # A field name, specified in the fields: section below
to_name: My Site # Must be valid text
to_email: [email protected] # Must be valid email address
cc_name: Info Person
cc_email: [email protected]
bcc_name: Manager Person
bcc_email: [email protected]
attach_files: false
# templates: # Override the global Twig templates for this form
# form: "@boltforms/form.twig"
# email: "@boltforms/email.twig"
# subject: "@boltforms/subject.twig"
# files: "@boltforms/file_browser.twig"
feedback:
success: Form submission sucessful
error: There are errors in the form, please fix before trying to resubmit
redirect:
target: page/another-page # A page path, or URL
query: [ name, email ] # Optional keys for the GET parameters
database:
contenttype:
name: comment # ContentType record to create
field_map:
# email: 'email' # Do not try to save this field to the ContentType
# content: 'content' # Form field "message" will be saved to the ContentType field "sent_message"
article_id: 'article_id'
username: 'username'
url: ~
attachments: ~
string_city_processor_string: ~
# path: ~
# timestamp: ~
# ip: ~
table: bolt_secret_table # Specific database table to write to
# uploads:
# subdirectory: showcase_files # The (optional) subdirectory for uploaded files
recaptcha: false # This setting is optional to use the overall default, false is the only valid value to disable for this form only.
fields:
content:
type: textarea
options:
required: true
label: Your message
attr:
# placeholder: Well, the other day I was thinking that maybe you ought to improve your website by adding...
class: myclass-message
username:
type: text
options:
required: true
article_id:
type: text
options:
required: true
hcaptcha:
type: captcha
options:
captcha_type: hcaptcha
recaptcha_v3:
type: captcha
options:
captcha_type: recaptcha_v3
recaptcha_v2:
type: captcha
options:
captcha_type: recaptcha_v2
# To not show a label at all, use "label: false"
label: Please complete this CAPTCHA
recaptcha_v2_invisible:
type: captcha
options:
captcha_type: recaptcha_v2
captcha_invisible: true
submit:
type: submit
options:
label: Submit my message »
attr:
class: button primary
article.twig
<section class="comments">
<header class="comments__header">
<h2 class="heading">Comments</h2>
{% if user %}
<div class="comments__new">
{% include "partials/comment/_comment_new.twig" with {"articleId": article.id} %}
</div>
{% else %}
<div class="comments__login">
<span>Login to comment</span>
{{ login_form() }}
</div>
{% endif %}
</header>
<hr/>
<div class="comments__list">
{% setcontent comments = "comments" where { path: app.request.pathInfo } order "-publishedAt" %}
{% for comment in comments %}
{% include "partials/comment/_comment.twig" with {"commentInfo": comment} %}
{% endfor %}
</div>
</section>
_comment_new.twig
{% if articleId is defined %}
{{ boltform('commentForm') }}
<form name="commentForm" class="form" method="post">
<div class="form__group">
<label class="form__label" for="content">Rašyti naują komentarą</label>
<textarea id="content" cols="51" rows="3" name="commentForm[content]" class="form__input" required></textarea>
</div>
<input type="hidden" name="commentForm[_token]" value="{{csrf_token('commentForm')}}">
<input type="hidden" name="commentForm[username]" value="{{user.username}}">
<input type="hidden" name="commentForm[article_id]" value="{{articleId}}">
<input type="hidden" name="commentForm[string_city_processor_string]">
<div class="form__group">
<input class="button" name="commentForm[submit]" type="submit" value="Rašyti">
</div>
</form>
{% endif %}
Unless I put {{ boltform('commentForm') }} above
element, this form does not work. I prefer to make my custom form instead of using shortcode to insert it.If I put {{ boltform('commentForm') }} above my form, when submitting it I get an error:
HTTP 500 Internal Server Error
Call to a member function sanitise() on null
But after hitting enter in URL, page is reloaded and record saved.
Not sure where the bug is. Would be thankful for any insights.
An exception has been thrown during the rendering of a template ("Connection could not be established with host "localhost:25": stream_socket_client(): Unable to connect to localhost:25 (Connection refused)").
Exceptions 2Logs 1Stack Traces 2
Twig\Error
RuntimeError
in public/theme/winkarch/holder_contact.twig (line 16)
boltforms 1.4.2
bolt 4.1.22
I don't receive notification emails to the recipient set with bcc_email while to_email and cc_email are working as expected.
No error messages, no matter if debug is on or off.
contact:
notification:
enabled: true
debug: false
subject: Nachricht via Kontaktformular
subject_prefix: '[foo]'
replyto_name: '{NAME}' # Email addresses and names can be either the
replyto_email: '{EMAIL}' # name of a field below or valid text.
to_name: User A
to_email: [email protected]
bcc_name: User B
bcc_email: [email protected]
[...]
I'm having some trouble implementing the captcha field. With either reCAPTCHA v3 or v2 checkbox, the field is rendered as a text type, although I can see the Symfony form type extends hidden type, so looks like something is not right there.
@andysh-uk might be able to shed some light on this as he submitted the original PR.
Also, using v3 I see warnings in the JS console about the callback function not being found.
Finally, it's not clear from the README that you have to also include the recaptcha JS in a <script> tag manually - which is fine, it's just not documented and I initially expected the recaptcha module to sort this for me.
Thanks
Using latest Bolt and Bolt Forms releases
in config.yaml we can see the feedback option
# feedback:
# success: Form submission sucessful
# error: There are errors in the form, please fix before trying to resubmit
# redirect:
# target: page/another-page # A page path, or URL
# query: [ name, email ] # Optional keys for the GET parameters
The redirect.target option works perfectly but the query option seems to be ignored in code.
No sign of ['query'] in src/EventSubscriber/Redirect and in entire extension files.
When "database" and "honeypot" are both activated, the form tries to insert the virtual field created by HoneyPot into the ContentType.
"leads" is my ContentType :
Can't set Field 'fax_name_state_company' of 'leads'. Make sure the Field is defined in the Leads ContentType
An inexplicable field with name="contact[string_city_processor_string]" appeared,
how to remove it (how can this be debugged)?
It appears at the end of any form template anyway, here is the full html of the field:
<div class="form-group">
<label class="control-label" for="contact_string_city_processor_string">String city processor string</label>
<input type="text" id="contact_string_city_processor_string" name="contact[string_city_processor_string]" tabindex="-1" autocomplete="off" class="form-control">
</div>
here is one of my form-config file:
notification:
enabled: true
debug: true
debug_smtp: true
debug_address: [email protected]
subject: "Message from site"
subject_prefix: ""
replyto_name: name # Email addresses and names can be either the
replyto_email: email # name of a field below or valid text.
to_name: Sale
to_email: [email protected]
from_name: name
from_email: email
feedback:
success: <b>Thank you.</b><br>Your request has been received.
error: There are errors in the form, please fix before trying to resubmit
submission:
ajax: true
database:
contenttype:
name: contact_form # save all form submissions to the quotations contenttype
field_map:
# timestamp: ~ # do not save the timestamp
# url: ~ # do not save the url
# path: ~ # do not save the path
# ip: ~ # do not save the ip
ignore_missing: true # ignore fields in the form that aren't defined in the ContentType
templates:
form: forms/contact/_contact.twig
fields:
name:
type: text
options:
required: true
label: Name
attr:
placeholder: Name
constraints: [NotBlank, { Length: { "min": 3, "max": 128 } }]
company:
type: text
options:
required: true
label: Company
attr:
placeholder: Company
constraints: [NotBlank, { Length: { "min": 3, "max": 128 } }]
email:
type: email
options:
required: true
label: E-mail
attr:
placeholder: E-mail
constraints: [NotBlank, { Length: { "min": 3, "max": 128 } }]
phone:
type: text
options:
required: false
label: Phone
attr:
placeholder: Phone
constraints: [NotBlank, { Length: { "min": 3, "max": 12 } }]
comment:
type: textarea
options:
required: false
label: Message
attr:
placeholder: Message
subscription:
type: checkbox
options:
required: false
label: Upgrade your skills by subscribing to our monthly newsletter
label_html: true
policy:
type: checkbox
options:
required: true
label: I've read the <a target='_blank' style='color:\#fb9024;' href='/privacy-policy/'>Privacy Policy</a> and I consent to the processing of my personal data.
label_html: true
submit:
type: submit
options:
label: Get in touch
attr:
class: button _submit _w-full _size-l
When there are multiple forms on a page (let's say form A and B), both with a Recaptcha field. When the submit button is clicked on form A, the page will reload with validation errors on form B.
I traced the issue to the function "onRecaptchaSubmitted", as this function is loaded up for each form that contains a Recaptcha field, so, when one form is submitted each instance of the function was called.
Have got a fix ready, where the form name is included in each function to prevent multiple submits.
somewhere in boltforms.yml
templates:
form: '@boltforms/form.html.twig'
email: '@boltforms/email_table.html.twig' # Replace with @boltforms/email.html.twig to send simple list-based emails.
subject: '@boltforms/subject.html.twig'
files: '@boltforms/file_browser.twig'
subject.html.twig ... where u go my friend?
vendor\bolt\forms\templates <<<< not here
Hello,
In the Twig view, can we display the form fields individually in order to format the form?
As would be the case with form_row() functions in a standard Symfony form.
Mapping ‘timestamp’ into a contenttype field results in:
Text field: 00000000423a013000000000110df7d6
Date field: Empty date selector
The fileupload does not store the path to the uploaded file in the content types.
When the file upload contenttype is "type = text" only the temporary
location is stored (in my case /tmp/php...
eg: /tmp/phpS9pEcf
).
The files itself are uploaded to:
projectRoot/uploads
eg:
conference\uploads\dffe8dd5_Uploaded file61dd9fb856f7ffSOME-FILE-NAME.jpg
I'm running:
$ php --version
PHP 7.2.24-0ubuntu0.18.04.6 (cli) (built: May 26 2020 13:09:11) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.24-0ubuntu0.18.04.6, Copyright (c) 1999-2018, by Zend Technologies
and
Bolt version5.1.1
and
Boltforms: Version: 1.4.12
(Attached you find the relevant file for you convenience.)
bolt-boltforms.yaml
# ...
contact:
database:
contenttype:
name: mycontenttype # ContentType record to create
feedback:
success: Message submission successful
error: There are errors in the form, please fix before trying to resubmit
fields:
name:
type: text
options:
required: false
foo:
type: file
submit:
type: submit
options:
label: Submit my message »
attr:
class: button primary
# ...
contenttypes.yaml
# ...
mycontenttypes:
name: mycontenttypes
singular_name: mycontenttype
fields:
name:
type: text
foo:
type: text
attachments:
type: text
# ...
index.twig (i use the base-2021 theme for this test)
{{ boltform('contact') }}
Please, help, My form config:
contact:
notification:
enabled: true
debug: false
debug_address: [email protected] # Email address used when debug mode is enabled
debug_smtp: false
subject: New message
subject_prefix: '[SITE]'
replyto_name: '{NAME}' # Email addresses and names can be either the
replyto_email: '{EMAIL}' # name of a field below or valid text.
to_name: 'SITE'
to_email: '[email protected] '
from_name: 'SITE'
from_email: '[email protected] '
feedback:
success: Message submission successful
error: There are errors in the form, please fix before trying to resubmit
redirect:
target: 'http://google.com' # A page path, or URL
fields:
name:
type: text
options:
label: false
required: true
attr:
placeholder: Your name...
class: uk-input uk-margin-bottom
constraints: [ NotBlank, { Length: { 'min': 3, 'max': 128 } } ]
email:
type: email
options:
label: false
attr:
placeholder: Your email...
class: uk-input uk-margin-bottom
constraints: [ NotBlank, Email ]
message:
type: textarea
options:
required: true
label: false
attr:
placeholder: Your message...
class: uk-textarea uk-margin-bottom
submit:
type: submit
options:
label: Submit Message
attr:
class: uk-button uk-button-primary uk-margin-bottom
Do I understand correctly that, in theory, there should be a redirect to google.com? But it doesn't happen.
I'm currently working on the CAPTCHA PR, and have pulled in the 1.0.5 and 1.0.6 releases today.
I'm getting the following error when the form is completed:
Unexpected "endfor" tag (expecting closing tag for the "if" tag defined near line 54).
in bolt-forms/templates/email_blocks.html.twig (line 66)
I haven't changed this file in my current branch - I believe the recent change to include the date fields is at fault:
{%- if field.type == 'file' %}
{{ block('file_field_value') }}
{%- if field.type in ['date', 'datetime', 'dateinterval']%}
{{ block('field_date') }}
{%- else %}
{{ block('field_value') }}
{%- endif %}
Should this second if
be elseif
?
{%- if field.type == 'file' %}
{{ block('file_field_value') }}
{%- elseif field.type in ['date', 'datetime', 'dateinterval']%}
{{ block('field_date') }}
{%- else %}
{{ block('field_value') }}
{%- endif %}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.