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

Add special service separator for indexed nesting #43

Closed
zaus opened this issue Jun 12, 2015 · 0 comments
Closed

Add special service separator for indexed nesting #43

zaus opened this issue Jun 12, 2015 · 0 comments

Comments

@zaus
Copy link
Owner

zaus commented Jun 12, 2015

See zaus/forms-3rdparty-xpost#11

Specifically, here add a case for [%] that will use the following function to prepare the destination field (key) for indexed nesting by the XPost plugin.

function placeholder_separator($post) {
    $new = array(); // add results to new so we don't pollute the enumerator
    // find the arrays and reformat keys with index
    foreach($post as $f => $v) {
        if(is_array($v)) {
            // for each item in the submission array,
            // get its numerical index and replace the
            // placeholder in the destination field

            foreach($v as $i => $p) {
                $k = str_replace('%i', $i, $f);
                $new[$k] = $p;
            }

            unset($post[$f]); // now remove original, since we need to reattach under a different key
        }
    }
    return array_merge($post, $new);
}
@zaus zaus closed this as completed Oct 23, 2015
zaus added a commit that referenced this issue Feb 26, 2016
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

1 participant