Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function actionCreate($customer_id = null)
- {
- $contact=new Contact;
- $contact->customer_id = $customer_id;
- $contact->owner_id = Yii::app()->user->id;
- $address['primary'] =new Address;
- $address['secondary'] =new Address;
- // Uncomment the following line if AJAX validation is needed
- // $this->performAjaxValidation($model);
- if(isset($_POST['Contact']))
- {
- if(isset($_POST['Address']))
- {
- $address['primary']->attributes=$_POST['Address']['primary'];
- $address['secondary']->attributes=$_POST['Address']['secondary'];
- if($address['primary']->save() && $address['secondary']->save())
- {
- $contact->attributes=$_POST['Contact'];
- $contact->primary_address_id = $address['primary']->id;
- $contact->secondary_address_id = $address['secondary']->id;
- if($contact->save())
- $this->redirect(array('view','id'=>$contact->id));
- }
- }
- }
- $this->render('create',array(
- 'contact'=>$contact,
- 'address' => $address,
- ));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement