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 8227551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:09:44+00:00 2026-06-07T16:09:44+00:00

Maybe I’m overlooking something, and hopefully this is done very easy. I have a

  • 0

Maybe I’m overlooking something, and hopefully this is done very easy.

I have a form and what I want in the end is the following result:

Fields which:

  • are mandatory/required
  • have an error currently
  • have help

should get an extra a-Tag after the label and an extra div, filled with the help and/or the error, if applicable.

What I got to work is, that required fields get the a-Tag by using this:

{% use 'form_div_layout.html.twig' with field_label as base_field_label %}

{% block field_label %}
    {{ block('base_field_label') }}

    {% if required %}
        <a href=""><span>&nbsp;</span></a>
    {% endif %}
{% endblock %}

So, what I tried already were different versions of this:

{% use 'form_div_layout.html.twig' with field_label as base_field_label %}

{% block field_label %}
    {{ block('base_field_label') }}

    {% if required or help is defined %}
        <a href=""><span>&nbsp;</span></a>
    {% endif %}
{% endblock %}

{% block field_row %}
    {% spaceless %}
        <div class="row">
            {% if required or help is defined %}
                <div>
                    {{ form_errors(form) }}
                    {{ help }}
                </div>
            {% endif %}

            {{ form_label(form) }}
            {{ form_widget(form, { 'attr': {'class': 'grid_4'} }) }}
        </div>          
    {% endspaceless %}
{% endblock field_row %}

And I can’t get this to work.

So my questions are:

  • Where do I get the help text from, which can also contain HTML? I tried this within the form builder without success – but at least with an exception:

    $builder    ->add('subject', 'text', array(
        'label' => 'Subject',
        'help' => 'Can be formatted content with <strong>HTML-Elements</strong>',
        ));
    
  • How can I tell that the current field has an error (to add a class to the row) and if so also display it? {{ form_errors(form) }} did not output anything, no matter where I place it within `field_row˚.

  • 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-07T16:09:45+00:00Added an answer on June 7, 2026 at 4:09 pm

    There is no help text, you have to create Form Extension for field and add it to default options.

    Example in SF 2.1 Beta 1:

    namespace Webility\Bundle\WebilityBundle\Form\Extension;
    
    use Symfony\Component\Form\FormInterface;
    use Symfony\Component\Form\FormViewInterface;
    use Symfony\Component\Form\FormBuilderInterface;
    use Symfony\Component\Form\AbstractTypeExtension;
    use Symfony\Component\OptionsResolver\OptionsResolverInterface;
    
    class HelpFormTypeExtension extends AbstractTypeExtension
    {
    
        public function buildView(FormViewInterface $view, FormInterface $form, array $options){
            $view->setVar('help', $options['help']);
        }
    
        public function getExtendedType(){
            return 'field';
        }
    
        public function setDefaultOptions(OptionsResolverInterface $resolver) {
            $resolver->setDefaults(array(
                'help' => null
            ));
        }
    }
    

    And register it as a service:

    <service id="webility.form.extension.help" class="Webility\Bundle\WebilityBundle\Form\Extension\HelpFormTypeExtension">
            <tag name="form.type_extension" alias="field" />
    </service> 
    

    For the errors question:
    Do you have any errors to print? Check that in controller if validation fails:

    echo '<pre>'; print_r( $form->getErrorsAsString() ); echo '</pre>'; exit;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Maybe this is a dumb question, but I have the following behavior in Visual
Maybe answer is very easy, but I can't find the right MySQL query which
Maybe I'm just going about this the wrong way, but I'm trying to have
Maybe I'm having a brain fart or something because it seems like this should
maybe this is a stupid question, but i have seen many Tuts that build
Maybe there is a package to do this, but I have not been able
Maybe I misunderstood this but from what I read I may have several problems
maybe the title is not very clear, let me elaborate. I have a python
Maybe this is a very simple question, but I just can not figure out.
maybe someone have good android app example with fragments and swipe? I want to

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.