I am working on create invoice form, it retrieves the data from 2 models Invoice and InvoiceDetail when I submit the form, it gives me the
error 500: undefined index:site_name.
public function actionCreate()
{
$model=new Invoice;
$detail = new InvoiceDetail();
if(isset($_POST['Invoice']))
{
$model->attributes=$_POST['Invoice'];
if(isset($_POST['InvoiceDetail'])){
$detail = $_POST['InvoiceDetail'];
foreach($detail as $key=>$details){
$det = new InvoiceDetail();
$det->attributes = array(
'invoice_id' => $model->id,
'site_name' => $detail['site_name'][$key],
'do_number' => $detail['do_number'][$key],
'description' => $detail['description'][$key],
'quantity' => $detail['quantity'][$key],
'rate' => $detail['rate'][$key],
'amount' => isset($detail['amount'][$key])?$detail['amount'][$key]:NULL,
);
$det->save(false);
}
}
}
$this->layout='columnInvoice';
$this->render('create',array(
'model'=>$model,
'detail' => $detail
));
}