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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:51:11+00:00 2026-06-11T07:51:11+00:00

I am developing a custom field for the Forms Component in Silex. The purpose

  • 0

I am developing a custom field for the Forms Component in Silex. The purpose of this field is to render and validate a captcha image/value.

I was able to add a FormExtension that registers my custom type.
I am injecting the $app['session'] to be able to store the captcha value in the session. Everything seems to work as expected until I start on touching the session.

Here’s the error I get:

Failed to start the session because headers have already been sent.

Hereunder is how I register my FormExtension and how it instanciates the custom field type:

$app->register(new FormServiceProvider());
$app['form.extensions'] = $app->share(
    $app->extend('form.extensions', function ($extensions) use ($app) {
        $extensions[] = new CaptchaFormExtension($app['captcha.options'], $app['session']);
        return $extensions;
    })
);

class CaptchaFormExtension extends AbstractExtension
{
    private $session;
    private $options;

    public function __construct($options = array(), Session $session)
    {
        $this->options = $options;
        $this->session = $session;
    }

    protected function loadTypes()
    {
        return array(
            new CaptchaType($this->options, $this->session)
        );
    }
}
  • 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-11T07:51:13+00:00Added an answer on June 11, 2026 at 7:51 am

    So I have figured out what the problem was.
    The error message was actually pretty much self-explanatory.

    Actually I don’t use the session prior to the calls in the CaptchaType so it only gets started at that point, which is, as the error message says, too late.

    Solution I have came up with is to explicitly start the session at the beginning of my controller action. I can then use the session inside the custom form type as I want to.

    $app->get('/contact', function() use ($app) {
    
        $app['session']->start();
    
        $form = $app['form.factory']->create(new ContactFormType(), new ContactMessage());
    
        ...
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing custom component derived from TCustomControl class. I would like to add
I'm developing a custom search control and setting its configuration based on this sample
I'm developing a lot of RadiantCMS applications, and this CMS uses custom radiant tags
I am developing a app in which I have to add custom contacts to
Does anyone have any good links for developing custom field and content types that
I am developing custom list field using Table Row Manager in blackberry.it displays list
I'm developing a custom module for my Magento installation (version 1.6.2.0). I registered a
Question We're developing a custom EventEmitter inspired message system in Objective-C. For listeners to
I'm developing a custom widget (inheriting from QWidget) to use as a control. How
I am developing a custom list-search tool. I have multiple custom properties to retain

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.