dongsuiying7773 2016-07-14 10:14
浏览 22
已采纳

表单字段未显示

I have an entity class named Ad, it contains fields like

id, banner, interstitial

The problem is when I try to create the form using this entity 'banner' text field is not displayed (not rendered), only the label.

I noticed that the id of the field is ad_banner if I change the id in browser inspect element, it will be displayed...
What is ad_banner in symfony, why it is hiding it?

I don't want to change the name of the field and I don't want to change the id from the twig because I want to keep it simple like this:

<div class="row">
    <div class="col-md-6">
        {{ form_start(form) }}
        {{ form_widget(form) }}
        {{ form_end(form) }}
    </div>
</div>

I tried to change the id of the field from the form builder, but without success. Thank you!

Ad class

/**
 * @var string
 *
 * @ORM\Column(name="banner", type="string", length=255, nullable=true)
 */
private $banner;

AdType form

/**
 * @param FormBuilderInterface $builder
 * @param array $options
 */
public function buildForm(FormBuilderInterface $builder, array $options) {
    $builder->add('account', EntityType::class, [
                'class' => 'AppBundle:Account',
                'choice_label' => 'name',
                'attr' => ['data-select' => 'true']
            ])
            ->add('banner', TextType::class, [
                'attr' => [
                    'placeholder' => 'Banner Id...'
                ]
            ])
            ->add('interstitial', TextType::class, [
                'attr' => [
                    'placeholder' => 'Interstitial Id...'
                ]
            ])
            ->add('submit', SubmitType::class, [
                'label' => 'Create',
                'attr' => [
                    'class' => 'btn btn-primary btn-sm'
                ]
            ])
    ;
}

generated Html

<div class="form-group">
    <label class="control-label required" for="ad_banner">Banner</label>
    <input type="text" id="ad_banner" name="ad[banner]" required="required" placeholder="Banner Id..." class="form-control">
</div>

enter image description here

I took out the style because I was thinking maybe some js is hiding it.

  • 写回答

1条回答 默认 最新

  • dtwzwmv87399 2016-07-14 10:31
    关注

    It is virus at your computer. Please remove it http://ru.wikihow.com/%D1%83%D0%B4%D0%B0%D0%BB%D0%B8%D1%82%D1%8C-Ad.yieldmanager.com and problems will gone

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程