summaryrefslogtreecommitdiff
path: root/framework/cli/views/shell/form
diff options
context:
space:
mode:
Diffstat (limited to 'framework/cli/views/shell/form')
-rw-r--r--framework/cli/views/shell/form/action.php37
-rw-r--r--framework/cli/views/shell/form/form.php39
2 files changed, 76 insertions, 0 deletions
diff --git a/framework/cli/views/shell/form/action.php b/framework/cli/views/shell/form/action.php
new file mode 100644
index 0000000..367c8ba
--- /dev/null
+++ b/framework/cli/views/shell/form/action.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * This is the template for generating the action script for the form.
+ * The following variables are available in this template:
+ * - $modelClass: the model class name
+ * - $viewName: the name of the view
+ */
+?>
+<?php
+$actionName=$modelClass;
+if(strrpos($modelClass,'Form')===strlen($modelClass)-4)
+ $actionName=substr($modelClass,0,strlen($modelClass)-4);
+?>
+public function action<?php echo $actionName; ?>()
+{
+ $model=new <?php echo $modelClass; ?>;
+
+ // uncomment the following code to enable ajax-based validation
+ /*
+ if(isset($_POST['ajax']) && $_POST['ajax']==='<?php echo $this->class2id($modelClass); ?>-form')
+ {
+ echo CActiveForm::validate($model);
+ Yii::app()->end();
+ }
+ */
+
+ if(isset($_POST['<?php echo $modelClass; ?>']))
+ {
+ $model->attributes=$_POST['<?php echo $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/cli/views/shell/form/form.php b/framework/cli/views/shell/form/form.php
new file mode 100644
index 0000000..cbf63bb
--- /dev/null
+++ b/framework/cli/views/shell/form/form.php
@@ -0,0 +1,39 @@
+<?php
+/**
+ * This is the template for generating the form view for the specified model.
+ * The following variables are available in this template:
+ * - $modelClass: the model class name
+ * - $attributes: a list of attribute names to receive form inputs
+ */
+?>
+<div class="form">
+
+<?php echo "<?php \$form=\$this->beginWidget('CActiveForm', array(
+ 'id'=>'".$this->class2id($modelClass)."-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($attributes 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
+}
+?>
+ <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