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

All Spacer fields displayed first, not in order #104

Closed
cd13sr opened this issue Nov 20, 2016 · 3 comments
Closed

All Spacer fields displayed first, not in order #104

cd13sr opened this issue Nov 20, 2016 · 3 comments
Labels

Comments

@cd13sr
Copy link

cd13sr commented Nov 20, 2016

When adding multiple Spacer field types to a page form, they are all being displayed first on the site and not in the order specified in the page's front-matter.

For example, these are the field types specified in the front-matter:

Spacer
Text
Text
Spacer
Text
Text

I would expect that same order when the form is rendered on the page, however, those two Spacer fields are being displayed at the top, before all the text fields.

Thanks.

@WeAreELIC
Copy link

FYI, this may help. In the plugin file: form > classes > form.php

Changing the unset function to an array_splice on line 201 fixed the issue for me.

Current lines 200-203

if (is_numeric($key) && isset($field['name'])) {
    unset($this->items['fields'][$key]);
    $key = $field['name'];
}

Update

if (is_numeric($key) && isset($field['name'])) {
    array_splice($this->items['fields'], $key);
    $key = $field['name'];
}

Thanks.

@flaviocopes
Copy link
Contributor

Replicated

@flaviocopes
Copy link
Contributor

@WeAreELIC your proposed solution seems to work for me too. Committing 👍

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

No branches or pull requests

3 participants