From c69e61801149d97992d0ddd6580a483cb668f1d7 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Wed, 13 Mar 2013 17:25:27 -0400 Subject: [PATCH] ActiveForm WIP --- framework/widgets/ActiveForm.php | 128 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 127 insertions(+), 1 deletion(-) diff --git a/framework/widgets/ActiveForm.php b/framework/widgets/ActiveForm.php index 77fd9fd..2bac53a 100644 --- a/framework/widgets/ActiveForm.php +++ b/framework/widgets/ActiveForm.php @@ -1,6 +1,132 @@ + * @since 2.0 + */ +class ActiveForm extends Widget { + /** + * @var mixed the form action URL (see {@link CHtml::normalizeUrl} for details about this parameter). + * If not set, the current page URL is used. + */ + public $action = ''; + /** + * @var string the form submission method. This should be either 'post' or 'get'. + * Defaults to 'post'. + */ + public $method = 'post'; + /** + * @var string the CSS class name for error messages. Defaults to 'errorMessage'. + * Individual {@link error} call may override this value by specifying the 'class' HTML option. + */ + public $errorMessageCssClass = 'errorMessage'; + /** + * @var array additional HTML attributes that should be rendered for the form tag. + */ + public $htmlOptions = array(); + /** + * @var boolean whether to enable data validation via AJAX. Defaults to false. + * When this property is set true, you should respond to the AJAX validation request on the server side as shown below: + *
+	 * public function actionCreate()
+	 * {
+	 *     $model=new User;
+	 *     if(isset($_POST['ajax']) && $_POST['ajax']==='user-form')
+	 *     {
+	 *         echo CActiveForm::validate($model);
+	 *         Yii::app()->end();
+	 *     }
+	 *     ......
+	 * }
+	 * 
+ */ + public $enableAjaxValidation = false; + /** + * @var boolean whether to enable client-side data validation. Defaults to false. + * + * When this property is set true, client-side validation will be performed by validators + * that support it (see {@link CValidator::enableClientValidation} and {@link CValidator::clientValidateAttribute}). + * + * @see error + * @since 1.1.7 + */ + public $enableClientValidation = false; + + + public function errorSummary($model, $options = array()) + { + } + + public function error($model, $attribute, $options = array()) + { + } + + public function label($model, $attribute, $options = array()) + { + } + + public function input($type, $model, $attribute, $options = array()) + { + return ''; + } + + public function textInput($model, $attribute, $options = array()) + { + return $this->input('text', $model, $attribute, $options); + } + + public function hiddenInput($model, $attribute, $options = array()) + { + return $this->input('hidden', $model, $attribute, $options); + } + + public function passwordInput($model, $attribute, $options = array()) + { + return $this->input('password', $model, $attribute, $options); + } + + public function fileInput($model, $attribute, $options = array()) + { + return $this->input('file', $model, $attribute, $options); + } + + public function textarea($model, $attribute, $options = array()) + { + } + + public function radio($model, $attribute, $value = '1', $options = array()) + { + } + + public function checkbox($model, $attribute, $value = '1', $options = array()) + { + } + + public function dropDownList($model, $attribute, $items, $options = array()) + { + } + + public function listBox($model, $attribute, $items, $options = array()) + { + } + + public function checkboxList($model, $attribute, $items, $options = array()) + { + } + public function radioList($model, $attribute, $items, $options = array()) + { + } }