V. Sambor
V. Sambor

Reputation: 13379

Form field not displayed

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.

Upvotes: 2

Views: 331

Answers (1)

Rinat
Rinat

Reputation: 429

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

Upvotes: 2

Related Questions