# give/4.18.0/src/Form/LegacyConsumer/Commands/SetupNewTemplateHook.php

GiveWP – Donation Plugin and Fundraising Platform, version 4.18.0. 38 lines.

- Page: https://pluginprobe.com/plugins/give/4.18.0/code/src/Form/LegacyConsumer/Commands/SetupNewTemplateHook.php
- Raw: https://pluginprobe.com/plugins/give/4.18.0/raw/src/Form/LegacyConsumer/Commands/SetupNewTemplateHook.php
- Modified: 2021-11-23T23:55:18+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/give/4.18.0/code/src/Form/LegacyConsumer/Commands/SetupNewTemplateHook.php#L10-L20`.

```php
<?php

namespace Give\Form\LegacyConsumer\Commands;

use Give\Form\LegacyConsumer\FieldView;
use Give\Framework\FieldsAPI\Group;

/**
 * @since 2.10.2
 */
class SetupNewTemplateHook implements HookCommandInterface
{

    /**
     * @since 2.10.2
     *
     * @param string $hook
     *
     * @return void
     */
    public function __invoke($hook)
    {
        // On the old hook, run the new hook and render the fields.
        add_action(
            "give_$hook",
            static function ($formId) use ($hook) {
                $collection = Group::make($hook);
                do_action("give_fields_$hook", $collection, $formId);
                $collection->walk(
                    static function ($node) use ($formId) {
                        FieldView::render($node, $formId);
                    }
                );
            }
        );
    }
}

```
