我想创建按钮Yii中的HTML按钮,点击我要调用一个UserController.php和Actioncreate。
我做这样的,
echo CHtml::button('Signup', array('button' => array('Users/create'))); ?>
但它给我下面的错误
htmlspecialchars() expects parameter 1 to be string, array given
这是堆栈跟踪
D:\wamp\www\yii\framework\web\helpers\CHtml.php(85)
73 */
74 public static $liveEvents = true;
75
76 /**
77 * Encodes special characters into HTML entities.
78 * The {@link CApplication::charset application charset} will be used for encoding.
79 * @param string $text data to be encoded
80 * @return string the encoded data
81 * @see http://www.php.net/manual/en/function.htmlspecialchars.php
82 */
83 public static function encode($text)
84 {
85 return htmlspecialchars($text,ENT_QUOTES,Yii::app()->charset);
86 }
87
88 /**
89 * Decodes special HTML entities back to the corresponding characters.
90 * This is the opposite of {@link encode()}.
91 * @param string $text data to be decoded
92 * @return string the decoded data
93 * @see http://www.php.net/manual/en/function.htmlspecialchars-decode.php
94 * @since 1.1.8
95 */
96 public static function decode($text)
97 {
Stack Trace
#0
+
D:\wamp\www\yii\framework\web\helpers\CHtml.php(85): htmlspecialchars(array("Users/create"), 3, "UTF-8")
#1
+
D:\wamp\www\yii\framework\web\helpers\CHtml.php(2216): CHtml::encode(array("Users/create"))
#2
+
D:\wamp\www\yii\framework\web\helpers\CHtml.php(140): CHtml::renderAttributes(array("button" => array("Users/create"), "name" => "yt1", "type" => "button", "value" => "Signup"))
#3
+
D:\wamp\www\yii\framework\web\helpers\CHtml.php(436): CHtml::tag("input", array("button" => array("Users/create"), "name" => "yt1", "type" => "button", "value" => "Signup"))
#4
–
D:\wamp\www\nurseweb\protected\views\site\login.php(50): CHtml::button("Signup", array("button" => array("Users/create")))
45 <?php echo $form->error($model,'rememberMe'); ?>
46