bfolliot/zf-nl2br

此软件包已被废弃且不再维护。没有建议的替代软件包。
此软件包最新版本(1.0.0)的许可信息不可用。

提供 ZF2 过滤器以实现 php nl2br 函数

1.0.0 2015-04-12 15:58 UTC

This package is not auto-updated.

Last update: 2020-08-25 13:21:49 UTC


README

提供 ZF2 过滤器以实现 php nl2br 函数

安装

BFolliot\Zf-Nl2br 通过 composer 提供。将 "BFolliot/Zf-Nl2br" 添加到您的 composer.json 列表中。您可以指定 BFolliot\Zf-Nl2br 的最新稳定版本

"BFolliot\Zf-Nl2br": "1.0.*"

要在您的 config/application.config.php 文件中启用模块,请将 BFolliot\ZfNl2br 添加到已启用模块的列表中。

用法

在您的输入过滤器配置中,将 nl2br 过滤器添加到过滤器结果中。示例表单

namespace Application\Form;

use Zend\InputFilter;
use Zend\Form\Form;

class Foo extends Form implements
    InputFilter\InputFilterProviderInterface
{
    public function __construct($name = null)
    {
        parent::__construct($name);

        $this->add(array(
            'name'    => 'text',
            'options' => array(
                'label' => 'Text'
            ),
            'attributes' => array(
                'type'  => 'textarea',
            ),
        ));
    }

    public function getInputFilterSpecification()
    {
        return array(
            'text'  => array(
                'required' => true,
                'filters'  => array(
                    array('name' => 'nl2br'),
                ),
            ),
        );
    }
}