Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8566273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:37:06+00:00 2026-06-11T17:37:06+00:00

What I want to do is get variables stored in form view. {% form_theme

  • 0

What I want to do is get variables stored in form view.

{% form_theme edit_form _self %}

{% block field_widget %}
{% spaceless %}
{% set type = type|default('text') %}
<input type="{{ type }}" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}/>

{# MY CODE #}
{% if type == "file" %}
<a class="BOpreview" href="{# NEED TO REPLACE VAR HERE #}">Aperçu</a>
{% endif %}

{# MY ATTEMPT #}
{{ form.title.get('value') }}
{{ form.vars.value.url }}

{% endspaceless %}
{% endblock field_widget %}

My form has properties like url, title, etc and I am trying to access them here to use it in the field widget block.

I searched for it and came on https://groups.google.com/forum/?fromgroups=#!topic/symfony2/onor9uFte9E that suggested:

{{ form.title.get('value') }}
{{ form.vars.value.url }}

which didn’t work for me.

Note: If I do a var_dump on $form->createView() in my controller, I get:

    object(Symfony\Component\Form\FormView)[331]
    private 'vars' => 
      array (size=15)
        'value' => 
          object(Panasonic\TestEtAvisBundle\Entity\Product)[168]
            protected 'reviewArray' => 
              object(Doctrine\ORM\PersistentCollection)[234]
                ...
            protected 'testArray' => 
              object(Doctrine\ORM\PersistentCollection)[221]
                ...
            protected 'fbshareArray' => 
              object(Doctrine\ORM\PersistentCollection)[317]
                ...
            private 'id' => int 2
            private 'name' => string 'Nom du produit' (length=14)
            private 'title' => string '<span>Titre </span>' (length=19)
            private 'image' => string 'bundles/testetavis/uploads/product/0d9d9550.png' (length=47)
            private 'fbImage' => string 'bundles/testetavis/uploads/product/facebook//product_e928cd96.jpg' (length=65)
            private 'description' => string '<span>Descriptif </span>' (length=24)
            private 'url' => string 'http://www.google.com' (length=21)
            private 'creationDate' => 
              object(DateTime)[210]
                ...
            private 'modificationDate' => 
              object(DateTime)[209]
                ...
            private 'isDeleted' => int 0
        'attr' => 
          array (size=0)
            empty
        'form' => 
          &object(Symfony\Component\Form\FormView)[331]
        'id' => string 'panasonic_testetavisbundle_producttype' (length=38)
        'name' => string 'panasonic_testetavisbundle_producttype' (length=38)
        'full_name' => string 'panasonic_testetavisbundle_producttype' (length=38)

I want to access that url for instance but can’t seem to be able to do it after many variations. Including use of {{ value }}, {{ value.url }}
But inspite of vars, I can do {{ full_name }} and get panasonic_testetavisbundle_producttype.

Any ideas?

Edit2: I found out the real problem…

Edit3: Seeing that this question is quite popular I decided to clarify on what I attempted to do in case it helps someone in the same situation. If you rely strictly on what the question asks, as I stated from my research and that Besnik supported are indeed correct.
Now what I wanted to do is for every input type file, get url from object used to render form and append a preview link, using retrieved url, beside the input type file.
If you try to get the form var of an input type “file” like this “{{ form.vars.value.url }}” in my code, this doesn’t work since, if I recall correctly, you receive a token instead of the url stored inside the object.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:37:07+00:00Added an answer on June 11, 2026 at 5:37 pm

    You can access the current data of your form via form.vars.value:

    {{ form.vars.value.title }}
    

    See Symfony2 Forms documentation: http://symfony.com/doc/current/book/forms.html#rendering-a-form-in-a-template

    Dump vars by using dump function:

    {{ dump(form.vars.value) }}
    

    If you are using subforms or want to have a value of a specific field:

    {{ form.FIELD.vars.VALUE }}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get 10 last variables from local storage. By 10 last i
I just want to get some thoughts on storing variables for JQuery's use. Example
I just to want to get an idea about how the register variables are
i bascially want to get the value of a variable from the codebehind to
I have a string containing the variable name. I want to get the value
In a bash script, I want to get the cursor column in a variable.
I have a variable which I get from database I want to output this
I want do puts blob but if the blob variable doesn't exist, I get
I want get the time used for a case so I can create an
I want get all of the Geom objects that are related to a certain

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.