Jun 11, 2009
How can i use embed forms or simgle form fields depend on a form field?
You have a register form with a field account_type and two embed forms Company and Address.
You want remove the embed Company form, when the field account_type is sfGuardUserProfile::TYPE_PRIVATE otherwise you want remove the embed Address form.
The solution is to override the bind method in your form.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | public function bind(array $taintedValues = null, array $taintedFiles = null) { // unset request param and validator if($taintedValues['account_type'] == sfGuardUserProfile::TYPE_PRIVATE) { unset( $taintedValues['Company'], $this->validatorSchema['Company'] ); } else { unset( $taintedValues['Address'], $this->validatorSchema['Address'] ); } parent::bind($taintedValues, $taintedFiles); } |
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.











Recent Comments