diff options
| author | Patrick Seeger <pseeger@ccwn.org> | 2012-04-13 23:11:05 +0200 |
|---|---|---|
| committer | Patrick Seeger <pseeger@ccwn.org> | 2012-04-13 23:11:05 +0200 |
| commit | 341cc4dd9c53ffbfb863e026dd58549c1082c7a7 (patch) | |
| tree | 1bbbed20313bafb9b063b6b4d894fe580d8b000f /framework/gii/generators/form/templates | |
Diffstat (limited to 'framework/gii/generators/form/templates')
| -rw-r--r-- | framework/gii/generators/form/templates/default/action.php | 33 | ||||
| -rw-r--r-- | framework/gii/generators/form/templates/default/form.php | 34 |
2 files changed, 67 insertions, 0 deletions
diff --git a/framework/gii/generators/form/templates/default/action.php b/framework/gii/generators/form/templates/default/action.php new file mode 100644 index 0000000..4e88e5b --- /dev/null +++ b/framework/gii/generators/form/templates/default/action.php @@ -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)); +}
\ No newline at end of file diff --git a/framework/gii/generators/form/templates/default/form.php b/framework/gii/generators/form/templates/default/form.php new file mode 100644 index 0000000..1405618 --- /dev/null +++ b/framework/gii/generators/form/templates/default/form.php @@ -0,0 +1,34 @@ +<?php +/** + * This is the template for generating a form script file. + * The following variables are available in this template: + * - $this: the FormCode object + */ +?> +<div class="form"> + +<?php echo "<?php \$form=\$this->beginWidget('CActiveForm', array( + 'id'=>'".$this->class2id($this->modelClass).'-'.basename($this->viewName)."-form', + '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 -->
\ No newline at end of file |
