Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fields of columns are not properly saved by using data.*.twig template #189

Closed
Pyth0ff opened this issue Sep 13, 2017 · 4 comments
Closed

Comments

@Pyth0ff
Copy link

Pyth0ff commented Sep 13, 2017

I'm using columns in my contact form and tried to save them as text. The field values of these columns are not saved in the text file.

form.md

---
menu: Contact
cache_enable: false
form:
    name: contact
    action: /home
    method: POST
    template: form-messages
    classes: 'c-contact-form'
    refresh_prevention: true
    fields:
        columns:
            type: columns
            fields:
                column0:
                    type: column
                    fields:
                        firstname:
                            label: FIRSTNAME
                            placeholder: FIRSTNAME_PLACEHOLDER
                            autocomplete: on
                            type: text
                            validate:
                                required: true
                                pattern: '[A-Za-z]{3,}'
                                message: FIRSTNAME_VALIDATION_HINT
                column1:
                    type: column
                    fields:
                        lastname:
                            label: SURNAME
                            placeholder: SURNAME_PLACEHOLDER
                            autocomplete: on
                            type: text
                            validate:
                                required: true
    buttons:
        submit:
            type: submit
            value: SUBMIT
    process:
        save:
            fileprefix: contact-
            dateformat: Ymd-His-u
            extension: csv
            body: "{% include 'forms/data.txt.twig' %}"
            operation: create
        message: 'Success!'
        reset: true
---

# Contact

Result: contact-20170913-183243-983373.txt

columns: 
@rhukster
Copy link
Member

Are you sure you are running the latest version of the form plugin? Ive just tested with your form page (i removed the action:, method: and classes:), and it successfully created a file and the values are there:

  1 firstname: first
  2 lastname: last
  3
~
~
"contact-20170914-152851-301009.csv" [dos] 3L, 36C

@Pyth0ff
Copy link
Author

Pyth0ff commented Sep 14, 2017

I'm using the latest version of Grav (v1.3.3) and Form plugin (v2.9.1). Also removed action:, method: and classes: from my demo form, but still have the same result.

I debugged the data.txt.twig (Line 4) and the highlighted condition is always true on my system. I would like to understand, where the input@ attribute is attached to the current field and what's the meaning of this attribute is. Is a column not a special type?

array:3 [
  "type" => "columns"
  "fields" => array:2 [
    "column0" => array:3 [
      "type" => "column"
      "fields" => array:1 [
        "firstname" => array:6 [
          "label" => "FIRSTNAME"
          "placeholder" => "FIRSTNAME_PLACEHOLDER"
          "autocomplete" => "on"
          "type" => "text"
          "validate" => array:3 [
            "required" => true
            "pattern" => "[A-Za-z]{3,}"
            "message" => "FIRSTNAME_VALIDATION_HINT"
          ]
          "name" => "firstname"
        ]
      ]
      "name" => "column0"
    ]
    "column1" => array:3 [
      "type" => "column"
      "fields" => array:1 [
        "lastname" => array:6 [
          "label" => "SURNAME"
          "placeholder" => "SURNAME_PLACEHOLDER"
          "autocomplete" => "on"
          "type" => "text"
          "validate" => array:1 [
            "required" => true
          ]
          "name" => "lastname"
        ]
      ]
      "name" => "column1"
    ]
  ]
  "name" => "columns"
]

@rhukster
Copy link
Member

Ok, I think i've found the problem. There's a list of fields that should have input@: false automatically set on them so they are treated as non-form fields, just a field to dig into deeper. However, some fields were 'ported' from admin (where these are defined) into the Form plugin, but the configuration was not added.

I have form + admin installed, so my admin plugin was setting these to input@: false, but really as they are also in the form plugin now, they should be set there too. I've fixed this in develop of form, so please try the latest develop branch or manually add the missing entries.

@Pyth0ff
Copy link
Author

Pyth0ff commented Sep 15, 2017

Yeah, on my installation I have currently no admin installed. I added your changes manually to my form plugin and now it work's fine. Thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants