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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:17:35+00:00 2026-05-30T14:17:35+00:00

I have a pretty simple form with some fields from a doctrine model. $this->widgetSchema[‘fields’]

  • 0

I have a pretty simple form with some fields from a doctrine model.

$this->widgetSchema['fields'] = new sfWidgetFormDoctrineChoice(array(
  'model'          => 'FieldModel',
  'expanded'       => true,
  'multiple'       => true,));

$this->validatorSchema['fields'] = new sfValidatorDoctrineChoice(array(
  'model'    => 'FieldModel',
  'multiple' => true,));

The fields are rendered in the form as checkboxes and I’m able to check and save correctly. This ‘fields’-field is converted to a json-structure and saved to the database as text. So far so good.

NOTE: The field ‘fields’ is stored as TEXT in the database, but the user should be able to select values from a list of checkboxes.

The problem arise when I want to have some of the checkboxes checked by default.

I tried to do:

$this->setDefault('fields', array('key1','key2','key3'));

Where ‘keyX’ correspond to the actual value of the primary key (string) for Field in the database.

If I do a

$this->getDefault('fields');

I get back exactly what I put in previously.

However, symfony is not outputing any of the checkboxes as checked. I have even tried to remove both the ‘expanded’ and ‘multiple’ options to the choice-widget so I get a simple SELECT-box and the provide only one value as default selected.

Setting default values for other widgets (text-inputs, choice, etc) work.

Btw; The Field-model is i18n. Don’t know if that matters here, since both storing / retrieving works as expected.

Also; the form is rendered as part of another form by means of include_partial(). Can that sabotage anything? In the ‘parent’ form class:

$this->embedRelation('TheRelationThatBugsMe');

And then in the _form.php for the ‘parent’:

include_partial('the_relation_that_bugs_me/form', array('form' => $form['TheRelationThatBugsMe']));

Does anyone have an idea where I might have gone wrong, or at least can give me some pointers as to where I should start digging?

[UPDATE]

If I create a new field in the form ‘fields2’ (that does not exist as a field in the database) and use the exact same code to create widget, validator and set defaults, then the defaults are rendered correctly. How come it doesn’t work setting defaults for a field mapped to a column in the database?

  • 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-05-30T14:17:36+00:00Added an answer on May 30, 2026 at 2:17 pm

    If you’re calling setDefault before updateDefaultFromObject gets called in sfDoctrineForm, then the object’s values will override form defaults if the object exists. updateDefaultsFromObject contains the relevant logic. You’ll have to call setDefault later, or override the method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pretty simple ASP.NET Web Form that looks a bit like the
I have a pretty simple Linq to XML query: var q = from c
I have a pretty simple UIScrollView defined inside Interface Builder. I've pasted in some
I have a PHP form that needs some very simple validation on submit. I'd
I have a pretty large form to develop and it could take some time
I have a form that works, but I need to have some fields hidden
This is a very simple form that I have found on the web (as
i have pretty simple simple question (i hope so). How do i change the
I have a pretty simple SQL I need to perform. I have a ProcessUser
I have a pretty simple question which perhaps someone familiar with Server/Client design &

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.