Advertisement
fernandezekiel

Untitled

Nov 15th, 2012
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. public function actionCreate($customer_id = null)
  2. {
  3.  
  4. $contact=new Contact;
  5. $contact->customer_id = $customer_id;
  6. $contact->owner_id = Yii::app()->user->id;
  7. $address['primary'] =new Address;
  8. $address['secondary'] =new Address;
  9. // Uncomment the following line if AJAX validation is needed
  10. // $this->performAjaxValidation($model);
  11.  
  12. if(isset($_POST['Contact']))
  13. {
  14.  
  15. if(isset($_POST['Address']))
  16. {
  17.  
  18. $address['primary']->attributes=$_POST['Address']['primary'];
  19. $address['secondary']->attributes=$_POST['Address']['secondary'];
  20.  
  21. if($address['primary']->save() && $address['secondary']->save())
  22. {
  23. $contact->attributes=$_POST['Contact'];
  24. $contact->primary_address_id = $address['primary']->id;
  25. $contact->secondary_address_id = $address['secondary']->id;
  26. if($contact->save())
  27. $this->redirect(array('view','id'=>$contact->id));
  28. }
  29.  
  30. }
  31.  
  32. }
  33.  
  34. $this->render('create',array(
  35. 'contact'=>$contact,
  36. 'address' => $address,
  37. ));
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement