Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/253.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何更改Zend表单批注中的表单文本框值?_Php_Forms_Zend Framework_Annotations - Fatal编程技术网

Php 如何更改Zend表单批注中的表单文本框值?

Php 如何更改Zend表单批注中的表单文本框值?,php,forms,zend-framework,annotations,Php,Forms,Zend Framework,Annotations,我有下面的注解。我需要更改zend控制器中的表单值 /** * @Annotation\Hydrator("Zend\Stdlib\Hydrator\ObjectProperty") * @Annotation\Name("LoginForm") * */ class User { /** Some comment to make this annotation work * @Annotation\Type("Zend\Form\Element\Text") * @

我有下面的注解。我需要更改zend控制器中的表单值

/** 
* @Annotation\Hydrator("Zend\Stdlib\Hydrator\ObjectProperty")
* @Annotation\Name("LoginForm")
* 
*/
class User
{
    /** Some comment to make this annotation work
    * @Annotation\Type("Zend\Form\Element\Text")
    * @Annotation\Required({"required":"true" })
    * @Annotation\Filter({"name":"StripTags"})
    * @Annotation\Options({"label":"Firstname: "})
    * @Annotation\Attributes({"id":"FirstnameId"})
    */
    public $username;
因此,在控制器中,我有:

$user       = new User();  
$builder    = new AnnotationBuilder();  
$this->form = $builder->createForm($user);  
现在我如何在这里设置或更改用户字段的值? 我尝试了
$this->form->getElement('Firstname')->setValue('FRANK')


但它不起作用?

好的,我找到了我的答案:$this->form->get('Firstname')->setValue('FRANK');欢迎来到堆栈溢出!我对你的问题进行了编辑,以使其格式更好,并消除一些混乱,但不清楚你在问什么。请添加更多关于您期望的内容和不起作用的内容的解释。