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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:11:38+00:00 2026-05-22T12:11:38+00:00

I have 2 forms: $patientForm and $investigationForm . They are both combined into one

  • 0

I have 2 forms: $patientForm and $investigationForm.

They are both combined into one view, so the user fills in the fields and 2 records are created in Patient table and Investigation table. Investigation table has a foreign key – to the patient name. So one patient can have many investigations.

So I obviously need the patient id to add it to an investigation record as a foreign key. However, the patient id isn’t created until the patient form is saved.

So I have devised the following function:

protected function processPatientInvestigation(sfWebRequest $request, sfForm $investigationForm, sfForm $patientForm)
{
    $patientForm->bind($request->getParameter($patientForm->getName()), $request->getFiles($patientForm->getName()));

    if ($patientForm->isValid() && $investigationForm->isValid() ) {        
        $patientForm->save();       
        $values = $request->getParameter($investigationForm->getName());
        $values['patient_id'] = $patientForm->getObject()->getId();
        $investigationForm->bind($values, $request->getFiles($investigationForm->getName()));
        $investigationForm->save();     
    }

The if statement always fails because $investigationForm isn’t valid until I give its form field a patient_id value. So this value is empty at this point. However, if I just took the isValid() check out for $investigation form and put it down later on after the $patientForm is saved. This means that if it failed validation and the user had missed a field, when they don’t click submit again, the whole function would run again meaning we’d have duplicate patient records.

So what I think the answer is, is making the patient_id field not be validated, so it can be empty and still pass the isValid() function.

Please let me know if this isn’t clear. Hope you can advise!

  • 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-22T12:11:38+00:00Added an answer on May 22, 2026 at 12:11 pm

    Try the following though this should really be done in the forms configure method.

    $patientForm->getValidator('patient_id')->addOption('required', false);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two forms, and so two different submit buttons, for one page (page
I have 2 forms in one page which are register and login forms and
I have a model w/ a manytomany relation to another model. They both have
I have forms with about 100 input fields each (textbox, textarea, radio, checkbox, file,
I'm using primefaces' accordion panel. Inside the tabs i have forms which are created
I have forms which work fine. I have a quiz which works fine. When
In a typical business application it is quite common to have forms that are
I have multiple forms for lots of products on my page and want to
I have Windows Forms UI, that allows me to enter format for string formatting
I have two forms in my project, form1 and form2. I have added a

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.