2

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.

8
  • It looks like you try to render in form fields which not exists in Entity. May be add option 'mapped' => false for Form class properties? Commented Jul 14, 2016 at 10:20
  • it exists in entity...and is added to the DOM but with display none... wait I'm gonna update with an image Commented Jul 14, 2016 at 10:22
  • In this case this issue comes from YieldManager and do not relate to Symfony Commented Jul 14, 2016 at 10:25
  • what is this YieldManager? and how can I get rid of it? Commented Jul 14, 2016 at 10:26
  • Ad.yieldmanager.com Commented Jul 14, 2016 at 10:29

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

2 Comments

is ad block bro... thank for your suggestion. I will accept the answer because it point me to the problem :D
Thanks! Good luck :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.