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

  • Home
  • SEARCH
  • 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 7040865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:58:09+00:00 2026-05-28T01:58:09+00:00

On Symfony 1.4.11 I have a boolean field that is set on a form

  • 0

On Symfony 1.4.11 I have a boolean field that is set on a form by a HTML checkbox. When the value is 0 (unchecked) then the HTML of the checkbox is

<input type="checkbox" value="" name="gift_type[valid]">

When I try and save the from it is always saved as zero, I assume because the input has no value.

The code I am using for the checkbox is generated by the symfony admin generator so I thought it would just work “out of the box”. If I uncheck a true value then that works as expected.

schema.yml

GiftType:
  columns:
    valid: { type: boolean, notnull: true, default: true }

BaseGiftTypeForm.class.php

$this->setWidgets(array(
    'valid' => new sfWidgetFormInputCheckbox()
));
$this->setValidators(array(
    'valid' => new sfValidatorBoolean(array('required' => false))
));
  • 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-28T01:58:10+00:00Added an answer on May 28, 2026 at 1:58 am

    Your HTML checkbox looks funny,
    are you sure it’s been generated by symfony? (the id is missing i.e.)

    <input type="checkbox" name="gift_type[valid]" checked="checked" id="gift_type_valid" />
    

    Anyway all the code you show is OK, there is no need to change the schema type! (ping @richrosa).
    sfValidatorBoolean return a boolean value, then it’s passed to the object, and then the object is saved. You have to debug your model. Out of the box, a boolean field in the Doctrine Admin Generator work perfectly fine.

    You can add this code in your GiftTypeForm class to help debug:

      protected function doUpdateObject($values)
      {
        var_dump($values);die();
        $this->getObject()->fromArray($values);
      }
    

    If you don’t see the “valid” key boolean, there is a validation process error, if it’s here, you have a model issue (have you overwrite the save method?).

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

Sidebar

Related Questions

I have a symfony form which have created_at and updated_at field for date. But
Normally, we can have the Symfony Form to output the field errors using the
I have a Symfony task that generates some files calls exec to a jar
We have FireSymfony that allows one to view the Symfony, PHP variables in a
I have an application that I'm converting to Symfony/Doctrine. It currently stores a serialized
Using Doctrine in symfony 1.4 I have several boolean columns defined (stored as a
Entities in symfony 2 have doctrine tags that are preceded with @ORM\ (eg @ORM\Entity).
I have a Symfony app that populates the widgets of a portal application and
I have a symfony 1.4 form with 2 embedded forms. The parent form has
On a current project which I'm currently working, i have a symfony task that

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.