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

The Archive Base Latest Questions

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

I have created a form in which i embed another form. My question is

  • 0

I have created a form in which i embed another form. My question is about this embedded form – I’m using a sfWidgetFormDoctrineChoice widget with option multiple set to true. The code for this embedded form’s configure method:

public function configure()
  {
    unset($this['prerequisite_id']);
    $this->setWidget('prerequisite_id', new sfWidgetFormDoctrineChoice(array(
        'model' => 'Stage',
        'query' => Doctrine_Query::create()->select('s.id, s.name')->from('Stage s')->where('s.workflow_id = ?', $this->getOption('workflow_id') ),
        'multiple' => true
    )));

    $this->setValidator('prerequisite_id', new sfValidatorDoctrineChoice(array(
        'model' => 'Stage',
        'multiple' => true,
        'query' => Doctrine_Query::create()->select('s.id, s.name')->from('Stage s')->where('s.workflow_id = ?', $this->getOption('workflow_id') ),
        'column' => 'id'
    )));
  }

I unset the prerequisite_id field because it is included in the base form, but I want it to be a multiple select.
Now, when I added the validator, everything seems to work (it passes the validation), but it seems like it has problems saving the records if there is more than one selection sent.

I get this PHP warning after submitting the form:

Warning: strlen() expects parameter 1 to be string, array given in
D:\Development\www\flow_dms\lib\vendor\symfony\lib\plugins\sfDoctrinePlugin\lib\database\sfDoctrineConnectionProfiler.class.php
on line 198

and more – I know, why – in symfony’s debug mode I can see the following in the stack trace:

at Doctrine_Connection->exec(‘INSERT INTO stage_has_prerequisites
(prerequisite_id, stage_id) VALUES (?, ?)’, array(array(’12’, ’79’),
‘103’))

So, what Symfony does is send to Doctrine an array of choices – and as I see in the debug sql query, Doctrine cannot render the query correctly.

Any ideas how to fix that? I would need to have two queries generated for two choices:

INSERT INTO stage_has_prerequisites (prerequisite_id, stage_id) VALUES (12, 103);
INSERT INTO stage_has_prerequisites (prerequisite_id, stage_id) VALUES (79, 103);

stage_id is always the same (I mean, it’s set outside this form by the form in which it is embedded).

I have spend 4 hours on the problem already, so maybe someone is able to provide some help.

  • 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:52:26+00:00Added an answer on May 28, 2026 at 1:52 am

    Well, I seem to have found a solution (albeit not the best one, I guess). Hopefully it’ll be helpful to somebody.

    Finally, after much thinking, I have concluded that if the problem comes from the Doctrine_Record not being able to save the record if it encounters an array instead of a single value, then the easiest solution would be to overwrite the save() method of the Doctrine_Record. And that’s what I did:

    class StageHasPrerequisites extends BaseStageHasPrerequisites
    {
      public function save(Doctrine_Connection $conn = null)
      {
        if( is_array( $this->getPrerequisiteId() ) )
        {
          foreach( $this->getPrerequisiteId() as $prerequisite_id )
          {
            $obj = new StageHasPrerequisites();
            $obj->setPrerequisiteId( $prerequisite_id );
            $obj->setStageId( $this->getStageId() );
            $obj->save();
          }
        }
        else
        {
          parent::save($conn);
        }
      }
    
      (...)
    
    }
    

    So now if it encounters an array instead of a single value, it just creates a temporary object and saves it for each of this array’s values.

    Not an elegant solution, definitely, but it works (keep in mind that it is written for the specific structure of the data and it’s just the effect of my methodology, namely See What’s Wrong In The Debug Mode And Then Try To Correct It Any Way Possible).

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

Sidebar

Related Questions

hii, I am using devexpress xtrascheduler.In this i have created one custom form which
I have created and html form which have a drop down list. This drop
I want to globalize my application. I have created a small form which asks
I have created a macro for excel which will pop up form that contains
I have created an form validation using ajax/php. Each text box is validated using
I am using ASP.NET2.0. I have created a download form with some input fields
I have created a form in C#.net which ask for key and check validity
Need a bit of help with a form. I have created a form which
I have created a windows form application which uses an SQL database. The database
I'm new to C# and I am using VS08, I have created a form

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.