$twoform = new TwoForm;
$this->embedForm('twoform', $twoform);
if($value == false) {
// unembedForm twoform HOW?
}
how can i make if $value == false then form twoform is not submit and not add to database? unset fields not working, because form is sending, but it has a NULL value.
You can do this to unset form
unset($this->widgetSchema['twoForm']);unset($this->validatorSchema['twoForm']);
unset($this->formFieldSchema['twoForm']);
But this won’t avoid posting the form in cas it was previously visible. You can replace validator to ignore posted values.
$this->setValidator('twoForm', new sfValidatorPass());If the exemple given is complete, the better is imho not to embed the form if $value == false
The database insertion depends on how your data is saved into it (sfDoctrineForm ?)