Skip to content

Conversation

@drzraf
Copy link

@drzraf drzraf commented Nov 21, 2018

When creating a form blueprint, the name matters. For example header.some.thing.
That makes impossible to reuse named fields.

Let's say a plugin defines such a foobar field:

# blueprints.yaml
form:
  validation: strict
  fields:
   foobar:
      type: select
      label: Default value if not overriden per-page
      data-options@: '\Grav\Plugin\MyPlugin::foobar'

But such value can be override on a page basis. The best is to reuse already defined blueprint:

# blueprints/modular/form.yaml
form:
  fields:
    # importing blueprint admin fields for per-page override
    import@:
      type: blueprints.yaml:form/fields # <-- this syntax is horribly difficult to deduce and undocumented
      context: plugins://myplugin

    # and override
    enabled: { unset@: true } # sure, this is not needed

    # `foobar` is not ok, in this context we must use `header.form.foobar`
    foobar:
      replace-name@: true
      name: header.form.foobar

See also: #23

When creating a form blueprint, the **name matters**. For example `header.some.thing`.
That makes impossible to reuse named fields.

Let's say a plugin defines such a `foobar` field:
```yaml
# blueprints.yaml
form:
  validation: strict
  fields:
   foobar:
      type: select
      label: Default value if not overriden per-page
      data-options@: '\Grav\Plugin\MyPlugin::foobar'
```

But such value can be override on a page basis. The best is to reuse already defined blueprint:
```yaml
# blueprints/modular/form.yaml
form:
  fields:
    # importing blueprint admin fields for per-page override
    import@:
      type: blueprints.yaml:form/fields # <-- this syntax is horribly difficult to deduce and undocumented
      context: plugins://myplugin

    # and override
    enabled: { unset@: true } # sure, this is not needed

    # `foobar` is not ok, in this context we must use `header.form.foobar`
    foobar:
      replace-name@: true
      name: header.form.foobar
```
@drzraf
Copy link
Author

drzraf commented Jun 28, 2019

ping

@mahagr mahagr self-requested a review July 5, 2019 06:10
@mahagr mahagr merged commit b24ba86 into rockettheme:develop Jan 6, 2020
mahagr pushed a commit that referenced this pull request Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants