Added new (clean) yii boilerplate
This commit is contained in:
33
framework/gii/generators/form/templates/default/action.php
Normal file
33
framework/gii/generators/form/templates/default/action.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* This is the template for generating the action script for the form.
|
||||
* - $this: the CrudCode object
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
$viewName=basename($this->viewName);
|
||||
?>
|
||||
public function action<?php echo ucfirst(trim($viewName,'_')); ?>()
|
||||
{
|
||||
$model=new <?php echo $this->modelClass; ?><?php echo empty($this->scenario) ? '' : "('{$this->scenario}')"; ?>;
|
||||
|
||||
// uncomment the following code to enable ajax-based validation
|
||||
/*
|
||||
if(isset($_POST['ajax']) && $_POST['ajax']==='<?php echo $this->class2id($this->modelClass); ?>-<?php echo $viewName; ?>-form')
|
||||
{
|
||||
echo CActiveForm::validate($model);
|
||||
Yii::app()->end();
|
||||
}
|
||||
*/
|
||||
|
||||
if(isset($_POST['<?php echo $this->modelClass; ?>']))
|
||||
{
|
||||
$model->attributes=$_POST['<?php echo $this->modelClass; ?>'];
|
||||
if($model->validate())
|
||||
{
|
||||
// form inputs are valid, do something here
|
||||
return;
|
||||
}
|
||||
}
|
||||
$this->render('<?php echo $viewName; ?>',array('model'=>$model));
|
||||
}
|
||||
44
framework/gii/generators/form/templates/default/form.php
Normal file
44
framework/gii/generators/form/templates/default/form.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* This is the template for generating a form script file.
|
||||
* The following variables are available in this template:
|
||||
* - $this: the FormCode object
|
||||
*/
|
||||
?>
|
||||
<?php echo "<?php\n"; ?>
|
||||
/* @var $this <?php echo $this->getModelClass(); ?>Controller */
|
||||
/* @var $model <?php echo $this->getModelClass(); ?> */
|
||||
/* @var $form CActiveForm */
|
||||
?>
|
||||
|
||||
<div class="form">
|
||||
|
||||
<?php echo "<?php \$form=\$this->beginWidget('CActiveForm', array(
|
||||
'id'=>'".$this->class2id($this->modelClass).'-'.basename($this->viewName)."-form',
|
||||
// Please note: When you enable ajax validation, make sure the corresponding
|
||||
// controller action is handling ajax validation correctly.
|
||||
// See class documentation of CActiveForm for details on this,
|
||||
// you need to use the performAjaxValidation()-method described there.
|
||||
'enableAjaxValidation'=>false,
|
||||
)); ?>\n"; ?>
|
||||
|
||||
<p class="note">Fields with <span class="required">*</span> are required.</p>
|
||||
|
||||
<?php echo "<?php echo \$form->errorSummary(\$model); ?>\n"; ?>
|
||||
|
||||
<?php foreach($this->getModelAttributes() as $attribute): ?>
|
||||
<div class="row">
|
||||
<?php echo "<?php echo \$form->labelEx(\$model,'$attribute'); ?>\n"; ?>
|
||||
<?php echo "<?php echo \$form->textField(\$model,'$attribute'); ?>\n"; ?>
|
||||
<?php echo "<?php echo \$form->error(\$model,'$attribute'); ?>\n"; ?>
|
||||
</div>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
<div class="row buttons">
|
||||
<?php echo "<?php echo CHtml::submitButton('Submit'); ?>\n"; ?>
|
||||
</div>
|
||||
|
||||
<?php echo "<?php \$this->endWidget(); ?>\n"; ?>
|
||||
|
||||
</div><!-- form -->
|
||||
Reference in New Issue
Block a user