-1

How can I use zend-form view helpers?

doing so... How can I use zend-form view helpers?

As a result, the message about the deprecated class contiguration enter image description here

What am I doing wrong?

Drakulitka
  • 41
  • 6

1 Answers1

1

Take a look at this https://github.com/zendframework/zend-expressive/issues/335

Here's how my factory looks like:

public function __invoke(ContainerInterface $container)
    {
        $config = $container->has('config') ? $container->get('config') : [];
        $config = isset($config['view_helpers']) ? $config['view_helpers'] : [];
        $manager = new HelperPluginManager($container, $config);

        return $manager;
    }

Update:

Since I was unclear let's try this again.

As you can see from the post on github, in order to remove the message about deprecated class you need to create a file config/autoload/zend-form.global.php with the contents:

<?php
use Zend\Form\ConfigProvider;

$provider = new ConfigProvider();
return $provider();

Doing so removes the need to add zend-form view helper configuration to service manager from within the factory that you are creating.
Meaning lines

$formConfig = new FormHelperConfig();
$formConfig->configureServiceManager($manager);

are no longer needed.

Also, method setServiceLocator of HelperPluginManager is deprecated so you change these two lines:

$manager = new HelperPluginManager(new Config($config));
$manager->setServiceLocator($container);

to one line:

$manager = new HelperPluginManager($container, $config);

As result your __invoke function will look like this:

public function __invoke(ContainerInterface $container)
{
    $config = $container->has('config') ? $container->get('config') : [];
    $config = isset($config['view_helpers']) ? $config['view_helpers'] : [];
    $manager = new HelperPluginManager($container, $config);

    return $manager;
}

You use view helpers inside your view template. Here you can find the list of all zend-form view helpers together with examples.

I hope this made thing more clear because I suck at explaining things.

  • How does this answer the question? Can you be more specific? – Raydot May 26 '16 at 22:41
  • Please provide detailed configuration structure? – Drakulitka May 27 '16 at 09:04
  • I use `AbstractActionFactory`, how can I implement it. [https://xtreamwayz.com/blog/2015-12-30-psr7-abstract-action-factory-one-for-all] – Drakulitka May 27 '16 at 09:31
  • @Drakulitka Forgive me but I have a feeling you don't know how to use view helpers. AbstractActionFactory has nothing to do with neither implementing or using view helpers. You use view helper within view template (.phtml file). – metalinspired May 27 '16 at 21:40
  • Thank you very much, I will try to implement Sorry for my English – Drakulitka May 28 '16 at 07:06