The form fields need to be named after their respective db fields.
The select tag/widget should be named ref_state_prov_id instead of 
province as you have named it (judging by your code).

Java Guy wrote:
> Hi, I'm doing my first PHP/symfony project and I've spent quite a bit
> of time reading all of the documentation.  I have just created a user
> registration page, and in it I am encountering an issue regarding how
> to deal with form fields that originate from the database, but which
> are not saved to the database.
> 
> I have select widgets which have US state names and Canadian province
> names, respectively.  The correct widget is displayed according to the
> country selected by the user in the UI.  In turn, I have a
> state_prov_id field in my AddressForm, which actually holds the
> reference to the correct province or state's ID.
> 
> I originally implemented the configure method of my AddressForm as
> follows:
> 
> <code>
>   public function configure()
>   {
>     // Select only provinces
>     $provinceCriteria = new Criteria();
>     $provinceCriteria->addJoin(RefStateProvPeer::COUNTRY_ID,
> RefCountryPeer::ID);
>     $provinceCriteria->add(RefCountryPeer::ISO_VALUE, 'CA',
> Criteria::EQUAL);
> 
>     // Select only states
>     $stateCriteria = new Criteria();
>     $stateCriteria->addJoin(RefStateProvPeer::COUNTRY_ID,
> RefCountryPeer::ID);
>     $stateCriteria->add(RefCountryPeer::ISO_VALUE, 'US',
> Criteria::EQUAL);
> 
>     $this->widgetSchema['province'] = new sfWidgetFormPropelChoice
> (array('model' => 'RefStateProv', 'add_empty' => 'Please select one',
> 'criteria' => $provinceCriteria),array('onchange' => 'setSubCountry
> (this.value)' ));
>     $this->widgetSchema['state'] = new sfWidgetFormPropelChoice(array
> ('model' => 'RefStateProv', 'add_empty' => 'Please select one',
> 'criteria' => $stateCriteria), array('onchange' => 'setSubCountry
> (this.value)'));
> </code>
> 
> But when I try to save the form, I get a propel error saying that
> state and province are not fields in the database.
> 
> What is the best way to deal with this?  The alternatives which come
> to mind are:
> 
> 1) Put the fields in a different form, which is not a propel form
> 2) Modify the save method or the updateObject method to exclude these
> two fields somehow
> 
> Your help is greatly appreciated.
> 
> Thanks,
> Steve
> 
> > 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to