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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:48:27+00:00 2026-05-17T21:48:27+00:00

I’m working on an e-commerce project and I got stuck at the cart update.

  • 0

I’m working on an e-commerce project and I got stuck at the cart update. Here I have to present a form using the contents of the current cart, with input fields containing the current quantities.

I checked the documentation and the forums, but I didn’t find anything useful. The problem is that i cannot declare the exact form fields in my form class because I don’t know how many fields will be there. I tried this:

class CartForm extends sfForm {
  public function configure()
  {
    $cart = sfContext::getInstance()->getUser()->getShoppingCart();
    foreach ($cart->getItems() as $item) {
      $widgetName = $item->getId().'_quantity';
      $this->widgetSchema[$widgetName] = new sfWidgetFormInput(
        array(),
        array(
            'class' => 'quantity-input',
            'id'    => null,
            'name'  => $widgetName
        )
      );
      $this->widgetSchema->setDefault($widgetName, $item->getQuantity());
      $this->validatorSchema[$widgetName] = new sfValidatorInteger(array(
        'required' => true,
        'min'      => 1
      ),
      array());
    }
    unset($cart);
    $this->getWidgetSchema()->getFormFormatter()->setRowFormat('%field%%error%%hidden_fields%');
  }
}

but I got some errors:

Fatal error: Cannot use object of type sfShoppingCart as array in /home/sfprojects/mdmall/lib/vendor/symfony/lib/form/sfForm.class.php on line 784

so this is not the right way. I tried to use raw fields without any form classes (and validators) but something very odd happens, instead of getting the $_POST values i get a 404 error because when I submit the form it doesn’t trigger this:

cart_update:
  url:    /cart/update.:sf_format
  class:  sfRequestRoute
  param:  { module: cart, action: update, sf_format: html }
  requirements: { sf_method: post }

If I remove the requirement, cart/update runs, but I dont have the $_POST data in the request object. Do you have any ideas?

  • 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-17T21:48:27+00:00Added an answer on May 17, 2026 at 9:48 pm

    These will help you with regard to dynamically adding form fields and working with validation of those fields:

    • Dynamic Emedded forms (but the process is similar for fields)
    • Dynamic Form Fields
    • Custom Validation
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from
i got an object with contents of html markup in it, for example: string
I have thousands of HTML files to process using Groovy/Java and I need to
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,

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.