Commit 62fc5cf6 by Qiang Xue

form WIP

parent 74f97ce5
...@@ -47,7 +47,7 @@ class ActiveForm extends Widget ...@@ -47,7 +47,7 @@ class ActiveForm extends Widget
* @var string the default CSS class for the error summary container. * @var string the default CSS class for the error summary container.
* @see errorSummary() * @see errorSummary()
*/ */
public $errorSummaryCssClass = 'yii-error-summary'; public $errorSummaryCssClass = 'error-summary';
/** /**
* @var string the CSS class that is added to a field container when the associated attribute is required. * @var string the CSS class that is added to a field container when the associated attribute is required.
*/ */
...@@ -180,15 +180,39 @@ class ActiveForm extends Widget ...@@ -180,15 +180,39 @@ class ActiveForm extends Widget
echo Html::endForm(); echo Html::endForm();
} }
/**
* Returns the options for the form JS widget.
* @return array the options
*/
protected function getClientOptions() protected function getClientOptions()
{ {
$options = array( $options = array(
'enableClientValidation' => $this->enableClientValidation, 'errorSummary' => '.' . $this->errorSummaryCssClass,
'enableAjaxValidation' => $this->enableAjaxValidation, 'validateOnSubmit' => $this->validateOnSubmit,
'errorCssClass' => $this->errorCssClass, 'errorCssClass' => $this->errorCssClass,
'successCssClass' => $this->successCssClass, 'successCssClass' => $this->successCssClass,
'validatingCssClass' => $this->validatingCssClass, 'validatingCssClass' => $this->validatingCssClass,
); );
if ($this->validationUrl !== null) {
$options['validationUrl'] = Html::url($this->validationUrl);
}
$callbacks = array(
'beforeValidateAttribute',
'afterValidateAttribute',
'beforeValidate',
'afterValidate',
);
foreach ($callbacks as $callback) {
$value = $this->$callback;
if (is_string($value)) {
$value = new JsExpression($value);
}
if ($value instanceof JsExpression) {
$options[$callback] = $value;
}
}
return $options;
} }
/** /**
...@@ -245,7 +269,9 @@ class ActiveForm extends Widget ...@@ -245,7 +269,9 @@ class ActiveForm extends Widget
* @param Model $model the data model * @param Model $model the data model
* @param string $attribute the attribute name or expression. See [[Html::getAttributeName()]] for the format * @param string $attribute the attribute name or expression. See [[Html::getAttributeName()]] for the format
* about attribute expression. * about attribute expression.
* @param array $options the additional configurations for the field object
* @return ActiveField the created ActiveField object * @return ActiveField the created ActiveField object
* @see fieldConfig
*/ */
public function field($model, $attribute, $options = array()) public function field($model, $attribute, $options = array())
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment