Code Monkey home page Code Monkey logo

form's Introduction

Flow Form Framework

An extensible and flexible framework to build web forms.

See https://flow-form-framework.readthedocs.org/en/latest/ for a detailed documentation.

Related Packages

This package implements the core of the Flow Form Framework and can be used directly within Neos Websites or Flow Applications. There are some useful related packages:

Neos Package Key Description Composer key / Packagist URL
Neos.Form The actual Form Framework core (this package) neos/form
Neos.Form.Builder A Form Builder IDE integrated to Neos CMS that allows for form *Definitions* to be created via the Backend interface and/or Fusion neos/form-builder
Neos.Form.YamlBuilder
(formerly Neos.FormBuilder)
The original Form Builder IDE that can be used with Flow alone to create YAML Form Definitions neos/form-yamlbuilder
(formerly neos/formbuilder)
Neos.Form.FusionRenderer A custom Form preset that allows Forms to be rendered via Fusion neos/form-fusionrenderer
Third party packages
PunktDe.FormPersistence Database persistence finisher, backend module to download data in different formats, export definition editor for field mapping, fine grained access rights, data retention mechanisms, .... punktDe/form-persistence
Wegmeister.DatabaseStorage Custom Form Finisher that helps storing formdata into the database and export it as Xlsx file wegmeister/databasestorage
Wegmeister.Recaptcha Custom Form Element that renders Googles reCAPTCHAs wegmeister/recaptcha
Honeypot Field Honeypot form field to spam-protect your forms without further disturbance. dl/honeypotformfield
Wwwision.Form.ContentReferences Example Form Element that renders Neos Content References wwwision/form-contentreferences
Wwwision.Form.MultiColumnSection Example Section Form Element that renders child Form Elements in multiple columns wwwision/form-multicolumnsection
Wwwision.Form.MultiFileUpload Example package providing a simple MultiFileUpload element for the Neos.Form framework wwwision/form-multifileupload
Wwwision.Form.SecureFileUpload Examples and helpers for implementing secure form uploads wwwision/form-securefileupload

Note: Feel free to create a Pull-Request with further related Form packages

form's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

form's Issues

listForms method in YamlPersistenceManager triggers warning when index is not found

The listForms method in YamlPersistenceManager triggers warning when the index is not found in the array containing settings from a YAML file.

In our case ContactForm.yaml is located in Packages/Sites/WE.SitePackage/Configuration which contains other non form setting YAML files as well.

When the code tries to access $form['identifier'] on line 105 it causes index not found warning what will be displayed in the Neos backend.

Suggested fix: add type check before access the $form array:

            if (!key_exists('type', $form) && $form['type'] === 'TYPO3.Form:Form'){
                $forms[] = array(
                    'identifier' => $form['identifier'],
                    'name' => isset($form['label']) ? $form['label'] : $form['identifier'],
                    'persistenceIdentifier' => $persistenceIdentifier
                );
            }

Return type of getUploadedImage() too strict?

In a project I ran into this problem:

Return value of Neos\Form\ViewHelpers\Form\UploadedImageViewHelper_Original::getUploadedImage() must be an instance of Neos\Media\Domain\Model\Image or null, instance of Neos\Flow\Persistence\Doctrine\Proxies\__CG__\Neos\Media\Domain\Model\ImageVariant returned

Similar to #118, see #111

Declaration must be compatible with ArrayAccess->offsetExists(offset)

Currently our CI fails because of this change:

public function offsetExists(mixed $identifier): bool

PHP Fatal error:  Declaration of Neos\Form\Core\Runtime\FormRuntime::offset  
Exists(Neos\Form\Core\Runtime\mixed $identifier): bool must be compatible with ArrayAccess::offsetExists($offset) in /Packages/Application/Neos.Form/Classes/Core/Runtime/FormRuntime.php on line 489

SCR-20230825-igan

It was introduced in #170

But we have PHP 8.1 in our project 🤔

Handle empty default values in `AbstractFinisher` correctly

currently the parseOption function behaves as follows:

  1. if the option is set (i.e. it exists and is not an empty string), resolve the object accessors (if a string) and returns the it
  2. otherwise, return the default option, if one exist, with resolved object accessors (if a string), or null if it doesn't

this means, assuming there is no default option, that an initial value of an empty string returns null.
however, a value containing an object accessor (e.g. {foo}) will never return null - even if the result is empty.

from my perspective there are two issues:

  • the same rules that apply to the option should apply to the default option (i.e. return null if empty).
  • after resolving the object accessors, null should be returned if the resulting string is an empty one (currently an empty string would be returned) - again, this should apply to both, options and default options

FormRuntime.render() causes exception

Neos.Form 5.0.0 throws

Exception in line 340 of /…/Flow_Object_Classes/Neos_Form_Core_Runtime_FormRuntime.php: Argument 1 passed to Neos\Flow\Mvc\ActionResponse::mergeIntoParentResponse() must be an instance of Neos\Flow\Mvc\ActionResponse, instance of Neos\Flow\Mvc\ActionRequest given, called in /…/Flow_Object_Classes/Neos_Form_Core_Runtime_FormRuntime.php on line 340

Caused by

$this->parentResponse = $request;

Invoke onSubmit callback on pages

Even though a \Neos\Form\Core\Model\Page is an instance of \Neos\Form\Core\Model\AbstractSection (thus implementing the onSubmit() function) the callback is only invoked for form elements.

It would be very useful to have that callback on the page level, too. For example in order to post-process form values and/or tweak the form definition upon submitted values.

Multistep form goto previous step: DateTime convert error

Reproduction

  • Create a Multistep Form where the first step contains a DatePicker
  • Fill the Value of the DatePicker, go to Step 2, and then go back to Step 1
  • An error gehts thrown:
    Could not convert target type "DateTime": No converter found which can be used to convert from "__PHP_Incomplete_Class" or "object" to "DateTime".

Possible solutions

  • The error definitely has something to do with Neos.Form/Classes/ViewHelpers/Form/DatePickerViewHelper.php and the getSelectedDate method (or the convert happening inside this method [Line 118])
  • Unfortunately it isn't completely clear to me why this error is thrown in the first place. A possible workaround would be to json_encode and json_decode the $date and then pass it to the convert.
// possible workaround in Neos.Form/Classes/ViewHelpers/Form/DatePickerViewHelper.php:118
$dateObject = json_decode(json_encode($date), true);
$date = $this->propertyMapper->convert($dateObject, 'DateTime');

Environment
neos/form: 5.2.0
neos/neos: 5.3.0
neos/flow: 6.3.0
php: 7.3

Support for multiple Fluid template paths in templatePathPattern, partialPathPattern and layoutPathPattern

Similar to how you override ex. TemplateRootPaths in Views.yaml and allow a array of paths, with support for fallback, the same functionality will be great for

            renderingOptions:
              templatePathPattern: 'resource://{@package}/Private/Form/{@type}.html'

when you define preset.

**Today: ** If you wan't to create a preset with a different Page than the default preset, you have to copy all files.

**Futury: ** Add a array of paths

I don't know if it's even possible to make complete use of the TemplatePaths object of the Fluid package.

I will personally dig into this in late april (after release of project) in case it's not solved at that time.
So all feedback gathered up untill then will be appreciated.

MaxLength is not registered in TextAreaViewhelper

<f:form.textarea property="{element.identifier}" id="{element.uniqueIdentifier}" class="{element.properties.elementClassAttribute}" additionalAttributes="{placeholder: '{element -> form:translateElementProperty(property: \'placeholder\')}'}" rows="{element.properties.rows}" cols="{element.properties.cols}" errorClass="{element.properties.elementErrorClassAttribute}" maxlength="{element.properties.maxlength}"/>

In Neos 4.1.7 I am getting the error that maxlength is no declared argument in TextAreaViewHelper.

Form does not conform to baseUri setting

Jira issue originally created by user @kitsunet:

The form package creates form urls by using the current http requests url, which might not necessarily be correct if the application is used behind a proxy. Instead it should use the baseUri + the current route values to create the uri.

An example which breaks behind proxies like varnish is the Neos Setup which produces wrong Uris.

Jira-URL: https://jira.neos.io/browse/NEOS-1759

Quickstart Example not complete

typo3/flow: ^3.1
typo3/form: ^2.0

I followed the steps

  • Create your first form
  • Render a form

In the frontend i get Catchable Fatal Error: Argument 1 passed to My\Package\Forms\TestForm_Original::build() must be of the type array, null given so there must be something more to do

Also the links in http://flow-form-framework.readthedocs.org/en/latest/quickstart.html are broken

Allow Resource Collection of file uploads to be defined

Currently files uploaded with the FileUpload Form Element always end up in the persistent resource collection.
For several reasons it would be nice to be able to specify a custom resource collection for the uploaded resources

NotEmptyValidator not working for radios and file inputs

The commit from #155 has the consequence that at least for radio buttons and file uploads the marking as mandatory field does not work anymore. Both elements have no request arguments if nothing was selected or uploaded, so the condition applies to these elements. As a result, the elements are not validated afterwards.

If you remove the condition, the validation works again. But this is surely not desired, so I looked a little further and if you move the line $registerPropertyPaths($element->getIdentifier()); to the beginning of the loop, the validation works as well. If I'm looking at this correctly after the short time, that should both solve the problem without breaking the change from #155.

Fatal error: Class 'TYPO3\SwiftMailer\Message' not found

This line in the EmailFinisher class does not ensure that the required Swiftmailer class is actually available (and causes a fatal error if you don't have Swiftmailer installed):
$mail = new \TYPO3\SwiftMailer\Message();

I suggest to either include Swiftmailer as dependency in composer.json or to check for installed Swiftmailer and throw an informative exception instead.

Discussion: How could it be possible to process submitted data between pages

Based on the topic raised here

https://discuss.neos.io/t/neos-form-persist-to-a-entity-between-each-page/2444/4

I would like to know what steps that could be taken, to make it possible to process submitted value in between pages. This is, without having to create a custom page element, but simple use the shipped Neos.Form:Page

Some of the thought I've had:

What if the user go back/forth in the form a.k.a. re-processing

This should not be the task of this patch to take care of that

How can we add any created data / outcome of processing to the form

Why us onSubmit not called for Page form element
Could this be a low-hanging fruit that we can pick simply by letting onSubmit be called also on Page element?

Form values no longer available in custom form elements

It used to be possible to get the form values in AbstractFormElement::onSubmit(). But $formRuntime->getFormState()->getFormValues() is empty since version 5.3.0.

Steps to reproduce

  1. Create a Form with a custom form element that renders the result of $formRuntime->getFormState()->getFormValues() in onSubmit
  2. Fill out the form and submit

Expected result

array(1)
 'password' (8) => 'aaaa' (4)

Actual result

array(empty)

Affected versions

neos/form 5.3.0

Render id={form.identifier} around ConfirmationFinisher

The <form> is rendered always withid={form.identifier}
After submitting the Form #{form.identifier} will be added to the URL.
If the Form is somewhere on the Page, the anchor #{form.identifier} will jump to the Form.

The Neos.Form.Builder:ConfirmationFinisher does NOT render id={form.identifier} around.
Because of the missing id, the Browser doesn't jump to the Confirmation Message and it maybe get lost somewhere on the page.

What about wrapping an id={form.identifier} around the Builder:ConfirmationFinisher?

I created a PR to fix this: #129

Make form state initialization more flexible

Recently we had several request for manipulating form state initialization like:

Initialize the state from some third party tool like SAP or marketing automation
Restore the form state after mail verification without persisting the complete state in the state hash
Restore the form state after returning from some third party authentication process

Make FormValues directly available in EmailFinisher template

The ConfirmationFinisher replaces placeholders in the form {someFieldName}.
The EmailFinisher expects the form values to be prefixed with formValues., e.g. {formValues.someFieldName}.

This feature suggests to make form Values directly accessible as view variables in the EmailFinisher, too.

Note: The formValues.* format should still be supported to ensure greater backwards compatibility

RedirectFinisher causes double slash

Steps to reproduce:

  • Create a form with a redirectFinisher pointing to a document node (I used the form builder package and created a node based form)
  • Publish the form
  • Fill out the form in the frontend and submit it

Expected behavior
You get redirected to the destination node and the uri is fine.

Actual behaviour
The uri contains a double-slash.

I think the reason is found here: https://github.com/neos/form/blame/3d4bccd33df9f2e4099312543d65b6198633c6c3/Classes/Finishers/RedirectFinisher.php#L58
$request->getHttpRequest()->getBaseUri() has a trailing slash and $uri has a leading slash.

As a workaround I changed the form-builder fusion to generate an absolute uri for the redirect:

prototype(Neos.Form.Builder:NodeBasedFinisherCollection) {
    itemRenderer {
        redirectFinisher {
            renderer {
                element.options {
                    [email protected] = ${true}
                }
            }
        }
    }
}

But I think the code, that prepends scheme and host to the uri should be fixed in the form package.

Create a new Release

Can you create a new release of this package?
Since there were for a longer time no new changes were added and there are changes in the master branch that are not in the latest release it would be really helpfull if you create a new release.

DatePicker field in multi-page forms can't get unserialized

Using a DatePicker field in a multi-page form throws an exception, when you try to re-render the field with a value set.

E.g.

  1. you set a Date on the first page
  2. go further to the next page
  3. step back to previous page

Exception

Could not convert target type “DateTime”: No converter found which can be used to convert from “__PHP_Incomplete_Class” or “object” to “DateTime”.

The unserialize of the form state causes this, because it is restricted to FormState class, so the DateTime object is ignored and handled as incomplete class.

This behavior was introduced by this changes:
c186327
ee593c2

Affected: Neos.Form >= 5.0

See also: https://discuss.neos.io/t/datetime-conversion-in-form/5007

Multi-Step forms fail when saving objects in the Form State

In my usecase the FormState holds asset objects like Neos\Media\Domain\Model\Document or Neos\Media\Domain\Model\Image. When form is rendered with initalized formState having one of the mentioned objects, an exception is thrown:

Absorbed Exception: Notice: property_exists(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition &quot;Neos\Media\Domain\Model\Document&quot; of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide an autoloader to load the class definition in .../Data/Temporary/Development/Cache/Code/Flow_Object_Classes/Neos_Flow_Persistence_Doctrine_PersistenceManager.php line 188

Is related to #126

RedirectFinisher does redirect after rendering

Scenario:
I use the Form-Framework via FormBuilder inside a Neos project. We have node based form with 2 finishers:

  • EMail-Finisher (sends a mail to an admin-mailbox)
  • Redirect-Finisher (redirects to a thankyou-document-node)

Expected behaviour:
After submitting the form (when validation does not complain), the users gets redirected to the thankyou-document-uri.

Actual behavirour:
The redirect is working, but before it happens, the document of the form is rendered and visible for 1-2s and then the redirct happens.

Can we achive that the redirect happens without the "intermediate rendering" of the form?

EMailfinisher - RecipientName check when RecipientAddress is in Array causes errors

Hello,
since the Recipientaddress may be an array of addresses the finisher checks, if the recipientName is an empty string with type check.
if (is_array($recipientAddress) && $recipientName !== '') { throw new FinisherException('The option "recipientName" cannot be used with multiple recipients in the EmailFinisher.', 1483365977); }

Since the E-Mailfinisher can be used with configured values from a yaml file, the recipientName will be transmitted as null when it is not set.

null !== ''
will return true and cause in a false validated recipientName so it's not possible to set recipientAddresses as an array.

[Feature] Pass node properties to form

It would be great, if you could pass data e.g. from your site node to the form and include them in a e.g. in a hidden form element.

Example use case
Registration
Passing details of an event so that you can use the form to register and predefine information e.g. event name, date, ... which will also be available in the finisher

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.