Php 如何更改Zend表单批注中的表单文本框值?
我有下面的注解。我需要更改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") * @
/**
* @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');欢迎来到堆栈溢出!我对你的问题进行了编辑,以使其格式更好,并消除一些混乱,但不清楚你在问什么。请添加更多关于您期望的内容和不起作用的内容的解释。