Symfony3“选项”占位符“不存在“。 [英] Symfony3 "The option "placeholder" does not exist."

查看:121
本文介绍了Symfony3“选项”占位符“不存在“。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在表单中,我希望占位符包含用户对其参数的当前值。 p>

下面是一个示例代码:

  // ... 
$ b $ form = $ this-> createFormBuilder($ user)
- > add('Username',TextType :: class,array(
'label'=>更改用户名,
'placeholder'=> $ userData [0] - > getUsername()
))
// ...


$ b

使用这样的值,我在浏览器中得到这个错误:

lockquote

选项占位符不存在。定义的选项包括:
action,allow_extra_fields,attr,auto_initialize,
block_name,by_reference,compound,constraints,
csrf_field_name ,csrf_message,csrf_protection,csrf_token_id,
csrf_token_manager,data,data_class,disabled,empty_data,
error_bubbling,error_mapping, extra_fields_message,
inherit_data,invalid_message,invalid_message_parameters,
label,label_attr,label_format,mapped,method,
post_max_size_message ,property_path,required,
translation_domain,trim,upload_max_size_message,
validation_groups。

问题仅在于参数本身,因为'data'=> $ userData [0] - > getUsername()可以工作并显示正确的信息。



以下是我的页面的使用参数:

  namespace AppBundle \Controller; 

使用Sensio \ Bundle\FrameworkExtraBundle\Configuration\Route;
使用AppBundle \Entity\Task;
使用Symfony \ Bundle \ FrameFrameworkBundle \ Controller \ Controller;
使用Symfony \Component\Form\Extension\Core\Type\TextareaType;
使用Symfony \Component\HttpFoundation\Request;
使用Symfony \Component\Form\Extension\Core\Type\TextType;
使用Symfony \Component\Form\Extension\Core\Type\SubmitType;
使用AppBundle \Entity\Post;
使用AppBundle \Entity\User;


解决方案

placeholder $ b $

  $ form = $ this-> createFormBuilder($ user)
- $ c $是一个html属性。

> add('Username',TextType :: class,array(
'label'=>更改用户名,
'attr'=> array(
'placeholder'= > $ userData [0] - > getUsername()




I want to create a user settings panel.

In the form I would like to have a placeholder with the current value the user has for his param.

Here is a sample code:

//...

$form = $this->createFormBuilder($user)
            ->add('Username', TextType::class, array(
                'label' => "Change UserName",
                'placeholder' => $userData[0]->getUsername()
            ))
//...

Using such values I get this error in the browser:

The option "placeholder" does not exist. Defined options are: "action", "allow_extra_fields", "attr", "auto_initialize", "block_name", "by_reference", "compound", "constraints", "csrf_field_name", "csrf_message", "csrf_protection", "csrf_token_id", "csrf_token_manager", "data", "data_class", "disabled", "empty_data", "error_bubbling", "error_mapping", "extra_fields_message", "inherit_data", "invalid_message", "invalid_message_parameters", "label", "label_attr", "label_format", "mapped", "method", "post_max_size_message", "property_path", "required", "translation_domain", "trim", "upload_max_size_message", "validation_groups".

The problem is only with the parameter itself because 'data' => $userData[0]->getUsername() works and displays the correct information.

Here are the use parameters of my page:

namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use AppBundle\Entity\Task;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use AppBundle\Entity\Post;
use AppBundle\Entity\User; 

解决方案

placeholder is a html attribute.

$form = $this->createFormBuilder($user)
        ->add('Username', TextType::class, array(
            'label' => "Change UserName",
            'attr' => array(
                'placeholder' => $userData[0]->getUsername()
                )
            )
        )

这篇关于Symfony3“选项”占位符“不存在“。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆