Commit 69b2b372 by Qiang Xue

form wip

parent 74246a23
......@@ -18,6 +18,7 @@ class LoginForm extends Model
{
public $username;
public $password;
public $rememberMe = true;
public function rules()
{
......@@ -25,6 +26,7 @@ class LoginForm extends Model
array('username', 'required'),
array('password', 'required'),
array('password', 'validatePassword'),
array('rememberMe', 'boolean'),
);
}
......
......@@ -5,10 +5,11 @@
*/
use yii\helpers\Html;
?>
<?php $this->beginPage(); ?>
<!DOCTYPE html>
<html>
<?php $this->beginPage(); ?>
<head>
<meta charset="utf-8" />
<title><?php echo Html::encode($this->title); ?></title>
<?php $this->head(); ?>
</head>
......@@ -18,5 +19,5 @@ use yii\helpers\Html;
<?php echo $content; ?>
<?php $this->endBody(); ?>
</body>
<?php $this->endPage(); ?>
</html>
<?php $this->endPage(); ?>
\ No newline at end of file
......@@ -14,13 +14,6 @@ use yii\helpers\Html;
<?php $form = $this->beginWidget('yii\widgets\ActiveForm'); ?>
<?php echo $form->field($model, 'username')->textInput(); ?>
<?php echo $form->field($model, 'password')->passwordInput(); ?>
<?php
$field = $form->field($model, 'username');
echo $field->begin() . "\n"
. $field->label() . "\n"
. Html::activeTextInput($model, 'username') . "\n"
. $field->error() . "\n"
. $field->end();
?>
<?php echo $form->field($model, 'rememberMe')->checkbox(); ?>
<?php echo Html::submitButton('Login'); ?>
<?php $this->endWidget(); ?>
\ No newline at end of file
......@@ -771,7 +771,7 @@ class Html
* @param array $items the data item used to generate the checkboxes.
* The array keys are the labels, while the array values are the corresponding checkbox values.
* Note that the labels will NOT be HTML-encoded, while the values will.
* @param array $options options (name => config) for the checkbox list. The following options are specially handled:
* @param array $options options (name => config) for the checkbox list. The following options are supported:
*
* - unselect: string, the value that should be submitted when none of the checkboxes is selected.
* By setting this option, a hidden input will be generated.
......@@ -785,7 +785,7 @@ class Html
*
* where $index is the zero-based index of the checkbox in the whole list; $label
* is the label for the checkbox; and $name, $value and $checked represent the name,
* value and the checked status of the checkbox input.
* value and the checked status of the checkbox input, respectively.
* @return string the generated checkbox list
*/
public static function checkboxList($name, $selection = null, $items = array(), $options = array())
......@@ -829,7 +829,7 @@ class Html
* @param array $items the data item used to generate the radio buttons.
* The array keys are the labels, while the array values are the corresponding radio button values.
* Note that the labels will NOT be HTML-encoded, while the values will.
* @param array $options options (name => config) for the radio button list. The following options are specially handled:
* @param array $options options (name => config) for the radio button list. The following options are supported:
*
* - unselect: string, the value that should be submitted when none of the radio buttons is selected.
* By setting this option, a hidden input will be generated.
......@@ -843,7 +843,7 @@ class Html
*
* where $index is the zero-based index of the radio button in the whole list; $label
* is the label for the radio button; and $name, $value and $checked represent the name,
* value and the checked status of the radio button input.
* value and the checked status of the radio button input, respectively.
* @return string the generated radio button list
*/
public static function radioList($name, $selection = null, $items = array(), $options = array())
......@@ -885,8 +885,9 @@ class Html
* If a value is null, the corresponding attribute will not be rendered.
* The following options are specially handled:
*
* - label: this specifies the label to be displayed. If this is not set, [[Model::getAttributeLabel()]]
* will be called to get the label for display. Note that this will NOT be [[encoded()]].
* - label: this specifies the label to be displayed. Note that this will NOT be [[encoded()]].
* If this is not set, [[Model::getAttributeLabel()]] will be called to get the label for display
* (after encoding).
*
* @return string the generated label tag
*/
......
......@@ -70,8 +70,8 @@ class BooleanValidator extends Validator
*/
public function validateValue($value)
{
return $this->strict && ($value == $this->trueValue || $value == $this->falseValue)
|| !$this->strict && ($value === $this->trueValue || $value === $this->falseValue);
return !$this->strict && ($value == $this->trueValue || $value == $this->falseValue)
|| $this->strict && ($value === $this->trueValue || $value === $this->falseValue);
}
/**
......
......@@ -30,6 +30,11 @@ class ActiveForm extends Widget
* Defaults to 'post'.
*/
public $method = 'post';
/**
* @param array $options the attributes (name-value pairs) for the form tag.
* The values will be HTML-encoded using [[encode()]].
* If a value is null, the corresponding attribute will not be rendered.
*/
public $options = array();
/**
* @var string the default CSS class for the error summary container.
......@@ -37,12 +42,14 @@ class ActiveForm extends Widget
*/
public $errorSummaryCssClass = 'yii-error-summary';
/**
* @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}).
* @var boolean whether to enable client-side data validation.
* Client-side validation will be performed by validators that support it
* (see [[\yii\validators\Validator::enableClientValidation]] and [[\yii\validators\Validator::clientValidateAttribute()]]).
*/
public $enableClientValidation = true;
/**
* @var array the default configuration used by [[field()]] when creating a new field object.
*/
public $enableClientValidation = false;
public $fieldConfig = array(
'class' => 'yii\widgets\ActiveField',
);
......
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