hey guys, im a new programmer and im in the middle of my first webpage… i have this problem… after searching for hours how to fix this… i decided to post it and see if someone could help me…
this is the view
<?php
/* @var $this CotizacionController */
/* @var $model Cotizacion */
$this->breadcrumbs=array(
'Cotizacions'=>array('index'),
$model->id,
);
$this->menu=array(
array('label'=>'List Cotizacion', 'url'=>array('index')),
array('label'=>'Create Cotizacion', 'url'=>array('create')),
array('label'=>'Update Cotizacion', 'url'=>array('update', 'id'=>$model->id)),
array('label'=>'Delete Cotizacion', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')),
array('label'=>'Manage Cotizacion', 'url'=>array('admin')),
);
?>
<h1>View Cotizacion #<?php echo $model->id; ?></h1>
<?php $this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
'id',
array(
'label'=>'Vendedor',
'value'=>$model->vendedor->nombre
),
array(
'label'=>'Cliente',
'value'=>$model->clientes->nombre
),
'fechacot',
'precio',
'fechaven',
'parrafo',
),
));
//copiar el la variable model de cotizacion a otra variable para evitar errores.
$cot = $model;
?>
<?php
echo CHtml::ajaxLink('clickMe', array('ajax'), array('update'=>'#ajax-results'));
?>
<div id="ajax-results">...</div>
this is the controller
<?php
class CotizacionController extends Controller
{
/**
* @var string the default layout for the views. Defaults to '//layouts/column2', meaning
* using two-column layout. See 'protected/views/layouts/column2.php'.
*/
public $layout='//layouts/column2';
/**
* @return array action filters
*/
public function filters()
{
return array(
'accessControl', // perform access control for CRUD operations
'postOnly + delete', // we only allow deletion via POST request
);
}
/**
* Specifies the access control rules.
* This method is used by the 'accessControl' filter.
* @return array access control rules
*/
public function accessRules()
{
return array(
array('allow', // allow all users to perform 'index' and 'view' actions
'actions'=>array('index','view'),
'users'=>array('*'),
),
array('allow', // allow authenticated user to perform 'create' and 'update' actions
'actions'=>array('create','update'),
'users'=>array('@'),
),
array('allow', // allow admin user to perform 'admin' and 'delete' actions
'actions'=>array('admin','delete','assign'),
"roles"=>array('admin'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionView($id)
{
$pet=new Peticion;
if(isset($_POST['Peticion']))
{
$pet->attributes=$_POST['Peticion'];
if($pet->save())
$this->redirect(array('/peticion/index'));
}
$this->render('view',array(
'model'=>$this->loadModel($id), 'pet'=>$pet
));
}
public function actionAjax($id)
{
$pet=new Peticion;
$cot=$model;
if(isset($_POST['Peticion']))
{
$pet->attributes=$_POST['Peticion'];
if($pet->save())
$this->redirect(array('/peticion/index'));
}
$this->renderPartial('//peticion/_form_', array('pet'=>$pet, 'cot'=>$cot));
}
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model=new Cotizacion;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Cotizacion']))
{
$model->attributes=$_POST['Cotizacion'];
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$this->render('create',array(
'model'=>$model,
));
}
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdate($id)
{
$model=$this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Cotizacion']))
{
$model->attributes=$_POST['Cotizacion'];
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$this->render('update',array(
'model'=>$model,
));
}
/**
* Deletes a particular model.
* If deletion is successful, the browser will be redirected to the 'admin' page.
* @param integer $id the ID of the model to be deleted
*/
public function actionDelete($id)
{
$this->loadModel($id)->delete();
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
if(!isset($_GET['ajax']))
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
}
/**
* Lists all models.
*/
public function actionIndex()
{
$dataProvider=new CActiveDataProvider('Cotizacion');
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
}
/**
* Manages all models.
*/
public function actionAdmin()
{
$model=new Cotizacion('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Cotizacion']))
$model->attributes=$_GET['Cotizacion'];
$this->render('admin',array(
'model'=>$model,
));
}
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Cotizacion the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model=Cotizacion::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
/**
* Performs the AJAX validation.
* @param Cotizacion $model the model to be validated
*/
protected function performAjaxValidation($model)
{
if(isset($_POST['ajax']) && $_POST['ajax']==='cotizacion-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
}
}
and this is the requested renderpartial view im trying to render
<?php
/* @var $this PeticionController */
/* @var $pet Peticion */
/* @var $form CActiveForm */
?>
<h1>Peticion</h1>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'peticion-form',
// Please note: When you enable ajax validation, make sure the corresponding
// controller action is handling ajax validation correctly.
// There is a call to performAjaxValidation() commented in generated controller code.
// See class documentation of CActiveForm for details on this.
'enableAjaxValidation'=>false,
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($pet); ?>
<div class="row">
<?php echo $form->labelEx($pet,'decreto_id'); ?>
<?php echo $form->DropDownList($pet,'decreto_id',CHtml::listData(Decreto::model()->findAll(),'id','ndecreto'), array('empty'=>'Seleccione decreto')); ?>
<?php echo $form->error($pet,'decreto_id'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($pet,'cotizacion_id'); ?>
<?php echo $form->textField($pet, 'cotizacion_id', array('readOnly'=>'true', 'value'=>$cot->id)); ?>
<?php echo $form->error($pet,'cotizacion_id'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton($pet->isNewRecord ? 'Create' : 'Save'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
the problem is that i just see the "…" below "ClickMe" and when i click it… nothing happens.
so please someone help me… what i did wrong? and please send me links about good yii tutorials