Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

How to access spacer in a blueprint?

form

Solved by Andy Miller View solution

Started by Oona O'Neil 9 years ago · 3 replies · 996 views
9 years ago

I'm trying to access a spacer text in a blueprint, but no success so far. Here's my .md file:

YAML
forms:
    contact_form:
        name: contact
        template: form-messages
        action: /home
        classes: contact__form__wrapper js-form-contact contact_form-validation-js
        fields:

            columns:
                type: columns

                fields:

                        column1:
                            type: column
                            fields:

                                - name: name
                                  placeholder: Name
                                  type: text
                                  novalidate: true
                                  classes: contact__form__input
                                - name: email
                                  placeholder: Email
                                  type: email
                                  novalidate: true
                                  classes: contact__form__input

                        column2:
                            type: column
                            fields:

                                - name: message
                                  placeholder: Message
                                  type: textarea
                                  size: long
                                  novalidate: true
                                  classes: contact__form__input--lg

                text:
                   type: spacer
                   text: All the fields are required

This blueprint is not working:

YAML
title: Contact
extends@: default

form:
  fields:
    tabs:
      type: tabs
      active: 1

      fields:
        gallery:
          type: tab
          title: Contact Fields

          fields:
            header.header:
              type: text
              label: Header 1
              validate:
                required: true
                header.forms.contact_form.text:
                  type: text
                  label: Info
                  validate:
                    required: true

Any ideas what I could do differently?

9 years ago

I've found information about the advanced blueprint features, but it doesn't seem to work for me. Am I using it in a correct way?

title: Contact
extends@: default

JS
form:
  fields:
    tabs:
      type: tabs
      active: 1

      fields:
        gallery:
          type: tab
          title: Contact Fields

          fields:
            header.header:
              type: text
              label: Header 1
              validate:
                required: true
            public function getFormFieldTypes()
            {
        return [
            'spacer' => [
                'input@' => true
            ]
        ];
    }
last edited 11/27/17 by Oona O'Neil
9 years ago Solution

Here's an example:

YAML
title: Group
form:
    validation: loose

    fields:
        spacer:
            type: spacer
            text: '<br>'

        groupname:
            type: text
            size: large
            label: PLUGIN_ADMIN.NAME
            disabled: true
            readonly: true
...
👍 1
9 years ago

I've been trying out grav for a while and asking quite a few questions here - most of issues have been addressed. Thanks for providing such a reliable support.

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1135 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 60 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 132 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 108 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 127 7 months ago