tritum / repeatable_form_elements

A custom form element called "Repeatable" for the awesome #TYPO3 form framework.
GNU General Public License v2.0
12 stars 16 forks source link

[question] [feature] no default repeatable element #33

Open ma-gu-16 opened 1 year ago

ma-gu-16 commented 1 year ago

Is there a possibility to create a repeatable element after click/user input and not an default one. ?

chrosey commented 1 month ago

@ma-gu-16 Thank you for your patience with this issue. Can you please describe it in more detail? I don't quite understand what you mean by creating an element after click/user input.

ma-gu-16 commented 1 month ago

If you visit a new page it should be possible to show default fields at the beginning. without user interaction to click the "add" button.

chrosey commented 1 month ago

Ok, here's what I understand: I as a visitor call a page with a form (and repeatable_elements). I expect that there are already fields that I can fill in. But currently I have to click on “add” to create input fields.

Or does your statement refer to the edit form in the backend: I as an editor edit a form in the backend. I expect that when I add the element repeatable_container, there are already some input fields in it.

ma-gu-16 commented 1 month ago

the first one. you as a visitor.

chrosey commented 1 month ago

I think I understand now: As a visitor, I can specify which form fields I can submit.

Example: The editor has created a form containing contact data and an (empty) repeatable_container in which a user can create any input fields from a minimum to a maximum number of times. To be specific: As a visitor, I decide that I can send 1 text field, 1 textarea, 2 checkboxes and 3 upload fields to the form recipient as long as the editor has allowed at least 7 copies to be created in the repeatable_container.

Is this correct?

ma-gu-16 commented 1 month ago

As a TYPO3 administrator, I configure a form, e.g., name, street, city, email address. Now, I want the email address to be a repeating element and a mandatory field. This means one email is required, but optionally, the visitor can add more emails, which, of course, must also be validated as mandatory and valid email addresses.

Currently, when I try to implement this, the repeating form (i.e., the email field) is not present initially. I have to click on the "+" to make an email field appear.

It should be possible to configure the form so that one or more sections are already rendered in the form. For example, the visitor comes to the form and already sees name, street, city, email address, email address, email address.

With the "+" button, they can add more, or with the "-" button, they can remove, but only as many as configured initially.

ma-gu-16 commented 1 month ago

same config for the opposite way... visitor is showing up and sees name,street,city and have to press "+" to add at least 1 required email.

chrosey commented 1 month ago

ok, i have configured an form.yaml as i understood your request. I cannot reproduce that its needed to click + to show the first email input. its there from the start.

can you confirm or adapt the form.yaml to show your case?


renderingOptions:
  submitButtonLabel: Submit
type: Form
identifier: issue-33
label: issue-33
prototypeName: standard
renderables:
  -
    renderingOptions:
      previousButtonLabel: 'Previous step'
      nextButtonLabel: 'Next step'
    type: Page
    identifier: page-1
    label: Step
    renderables:
      -
        defaultValue: ''
        type: Text
        identifier: text-1
        label: Name
      -
        defaultValue: ''
        type: Text
        identifier: text-2
        label: Street
      -
        defaultValue: ''
        type: Text
        identifier: text-3
        label: City
      -
        properties:
          minimumCopies: 0
          maximumCopies: 10
          showRemoveButton: true
          copyButtonLabel: Copy
          removeButtonLabel: Remove
        type: RepeatableContainer
        identifier: repeatablecontainer-1
        label: 'Repeatable container'
        renderables:
          -
            defaultValue: ''
            type: Email
            identifier: email-1
            label: Email
            validators:
              -
                identifier: EmailAddress
              -
                identifier: NotEmpty
            properties:
              fluidAdditionalAttributes:
                required: required
ma-gu-16 commented 1 month ago

same config for the opposite way... visitor is showing up and sees name,street,city and have to press "+" to add at least 1 required email.

ma-gu-16 commented 1 month ago

minimumCopies: 0 then there should be nothing. ?

chrosey commented 1 month ago

minimumCopies: 0 means, there is only the original input element and no need to copy this item.

if you set it to minimumCopies: 1, then you need to copy the original input element at least once.

ma-gu-16 commented 1 month ago

yes and my feature request, is: it should be possible to start with no default.

chrosey commented 1 month ago

ok, thank you. i will have a look into this.