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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:21:00+00:00 2026-05-26T10:21:00+00:00

I cannot get DB values of games to be selected: Game: actAs: Timestampable: ~

  • 0

I cannot get DB values of games to be selected:

Game:
  actAs:
    Timestampable: ~
  columns:
    id: { type: integer(4), primary: true, autoincrement: true, unsigned: true }
    game_name: { type: string(100), notnull: true }
    logo: { type: string(100), notnull: true, comment: "Game Logo" }
  indexes:
    it:
      fields: game_name
      type: unique

Campaign:
  actAs:
    Timestampable: ~
  columns:
    id: { type: integer(4), primary: true, autoincrement: true, unsigned: true }
    name: { type: string(100), notnull: true }
    percentage: { type: integer(4), notnull: true, unsigned: true }
    is_active: { type: integer(1), notnull: true, unsigned: true }
    start: { type: datetime, notnull: true }
    end: { type: datetime, notnull: true }

CampaignGames:
  actAs:
    Timestampable: ~
  columns:
    id: { type: integer(4), primary: true, autoincrement: true, unsigned: true }
    campaign_id: { type: integer(4), notnull: true, unsigned: true }
    game_id: { type: integer(4), notnull: true, unsigned: true }
  indexes:
    tc:
      fields: [campaign_id, game_id]
      type: unique
  relations:
    Campaign: { onDelete: CASCADE, local: campaign_id, foreign: id, foreignAlias: CampaignCampaignGames }
    Game: { onDelete: CASCADE, local: game_id, foreign: id, foreignAlias: GameCampaignGames }

I have added games checkbox here which belongs to Game model to let the user add games to CampaignGames, but unfortunately they never checked… And these values are present in DB.

class AdminconsoleCampaignForm extends CampaignForm
{

public function configure()
{
    parent::configure();

    $this->widgetSchema['is_active'] = new sfWidgetFormSelectRadio(array(
        'choices' => array(1 => 'On', 0 => 'Off'),
    ));

    $games = Doctrine_Core::getTable('Game')->getGames();

    $this->widgetSchema['game_id'] = new sfWidgetFormSelectCheckbox(array(
        'choices' => $games
    ));

    $this->validatorSchema['game_id'] = new sfValidatorChoice(array(
        'choices' => array_keys($games)
        , 'multiple' => true
        , 'required' => false
    ));

    $this->removeFields();

}

Also tried to use

$this->widgetSchema['game_id']->setDefault(array($data));

No luck. How to resolve it? I’m really stuck on that.

  • 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-26T10:21:01+00:00Added an answer on May 26, 2026 at 10:21 am

    There are two things that caught my attention:

    1. You’re not using Doctrine’s boolean data type

    Try changing your schema.yml to the following:

    Campaign:
      [...]
      columns:
        [...]
        is_active:
          type: boolean
          notnull: true
          default: 0 # Or whichever default value you prefer
        [...]
    

    This way Symfony/Doctrine will take care of anything regarding the is_active row of your Campaign record.

    If you now rebuild your model your BaseCampaignForm.class.php will define the is_active widget automatically like this:

    $this->setWidgets(array(
      [...]
      'is_active' => new sfWidgetFormInputCheckbox(),
      [...]
    );
    
    $this->setValidators(array(
      [...]
      'ist_active' => new sfValidatorBoolean(array('required' => false)),
      [...]
    );
    

    Note: That required is set to false is there because if a checkbox isn’t selected it’s not posted either. The sfValidatorBoolean takes care of this and disables the value all by itself. If you would set it to true than the user wouldn’t be able to uncheck the box and submit the form without a validator exception.

    2. You tried to set form object defaults in its form’s widget

    In your code you used:

    $this->widgetSchema['game_id']->setDefault(array($data));
    

    This won’t work because you’re using a Form with an object attached to it (a BaseFormDoctrine). All the default values are taken right out of the object assigned to that form (in your case a Campaign object because you’re extending CampaignForm).

    (Major pitfall) If you want to set default values on a form object you have to set them on the form object itself :

    $this->getObject()->setGameId($id);
    

    Default object values can’t be set using the object form’s widgets. These default values will always be overwritten by the actual object values (which makes sense because the form represents the object).

    Glad if I was able to help you in some way.

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

Sidebar

Related Questions

I have set ridiculous padding values and cannot get padding to extend the total
I have an issue where I cannot seem to get the values to re-populate
I cannot get a two-way bind in WPF to work. I have a string
I cannot get the internet explorer web developer tool bar to work with a
I cannot get std::tr1::shared_ptr for my WinMobile project since the STL for WinCE is
I cannot get my SID working ... <?php session_start(); // Or maybe pass along
I cannot get Bindable LINQ to work with VB.NET for the life of me.
I cannot get the background to stretch behind the contentbox. The strange thing is,
I cannot get the jQuery slideDown function to work on <table> elements. They just
I cannot get the DropDownHeight of the ComboBox set properly to display all the

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.