我是symfony1.4.20的新手。这是我的代码
<script type="text/javascript">
$(document).ready(function(){
$("#user_username").focus();
});
</script>
<div id="login">
<h2>Please Login... </h2>
<form action="<?php echo url_for('login/index') ?>" method="POST">
<?php echo $form->renderHiddenField()?>
<?php echo $form->renderGlobalErrors()?>
<?php echo $form->['username']->renderLabel()?>
<?php echo $form->['username']?>
<?php echo $form->['password']->renderLabel()?>
<?php echo $form->['password']?>
<input type="submit" name="Login" value="Login" />
<?php if($form->hasErrors()): ?>
<div id="errorBox">
Check the following errors: <br />
<ul>
<?php foreach($form->getErrorSchema()->getErrors() as $error ): ?>
<li><?php echo $error ?></li>
<?php endforeach ; ?>
</ul>
<?php endif;?>
</form>
比我收到的消息错误
Parse error: syntax error, unexpected '[', expecting T_STRING or T_VARIABLE or '{' or '$' in D:\Lab\WhoDoWhat\apps\userlogin\modules\login\templates\indexSuccess.php on line 12
它意味着它在线上的启动错误
<?php echo $form->['username']->renderLabel()?>
任何人都有解决方案吗?谢谢
答案 0 :(得分:1)
->
用于引用方法或属性。使用[]
语法时,您不应该使用它。删除->
,使其变为:
<?php echo $form['username']->renderLabel()?>