小编rog*_*ila的帖子

Symfony Form - 类型为"string或Symfony\Component\Form\FormTypeInterface"的预期参数,给出"数组"

我创建了一个带有学说的表格.如果我没有通过任何选项,它会工作,如下所示:

$builder
    ->add('name')
    ->add('password', 'password')
    ->add('password_repeat', 'password')
    ->add('email', 'email')
    ->add('save', 'submit')
;
Run Code Online (Sandbox Code Playgroud)

但是,如果我添加一个带有选项的数组,就像文档(http://symfony.com/doc/current/book/forms.html#book-form-creating-form-classes)那样,我收到的错误是:

预期参数类型为"string或Symfony\Component\Form\FormTypeInterface","数组"给出

这是由学说创建的formtype:

<?php

namespace MainBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class UserType extends AbstractType
{
/**
 * @param FormBuilderInterface $builder
 * @param array $options
 */
public function buildForm(FormBuilderInterface $builder, array $options)
{

    $builder
        ->add('name') //if I put ->add('name', array('label' => 'Your name')) I get the error
        ->add('password', 'password')
        ->add('password_repeat', 'password')
        ->add('email', 'email')
        ->add('save', 'submit')
    ;

}

/**
 * @param OptionsResolverInterface $resolver
 */
public function …
Run Code Online (Sandbox Code Playgroud)

php forms arrays symfony doctrine-orm

8
推荐指数
1
解决办法
1万
查看次数

Wordpress仅在主页面中缩小html

我正在使用此代码来缩小wordpress中的HTML输出.它在主页面和帖子页面上都很完美,但在管理部分它会导致很多问题.

function minify_html(){
    ob_start('html_compress');
}

function html_compress($buffer){

    $search = array(
        '/\n/',         // replace end of line by a space
        '/\>[^\S ]+/s',     // strip whitespaces after tags, except space
        '/[^\S ]+\</s',     // strip whitespaces before tags, except space
        '/(\s)+/s',     // shorten multiple whitespace sequences,
        '~<!--//(.*?)-->~s' //html comments
    );

    $replace = array(
        ' ',
        '>',
        '<',
        '\\1',
        ''
    );

    $buffer = preg_replace($search, $replace, $buffer);

    return $buffer;
}

add_action('wp_loaded','minify_html');
Run Code Online (Sandbox Code Playgroud)

使用'the_post'代替'wp_loaded'只会缩小帖子,但我希望能够将主页面和帖子页面缩小到100%,但管理部分没有任何内容.如何组合操作以进行管理?

谢谢!

html php wordpress action minify

5
推荐指数
1
解决办法
180
查看次数

标签 统计

php ×2

action ×1

arrays ×1

doctrine-orm ×1

forms ×1

html ×1

minify ×1

symfony ×1

wordpress ×1