Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.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
Twig 在细枝模板中设置文本区域值_Twig_Symfony 2.8 - Fatal编程技术网

Twig 在细枝模板中设置文本区域值

Twig 在细枝模板中设置文本区域值,twig,symfony-2.8,Twig,Symfony 2.8,我需要为表单设置要编辑的值。我需要在文本区域设置文本。我在html.twig文件中尝试了以下内容: <div class="form-group"> {{ form_widget(blog_form.post_subheading1, { 'attr': {'class': 'form-control', 'placeholder': 'Enter Subheading 1', 'value': post_data.postSubheading1 } }) }}

我需要为表单设置要编辑的值。我需要在文本区域设置文本。我在html.twig文件中尝试了以下内容:

<div class="form-group">
      {{ form_widget(blog_form.post_subheading1, { 'attr': {'class': 'form-control', 'placeholder': 'Enter Subheading 1', 'value': post_data.postSubheading1 } }) }}
      {{ form_errors(blog_form.post_subheading1) }}
    </div>

您可以在类型文件中添加
数据
,如下所示:

->add('post_intro', 'textarea', 
      'attr' => array('cols' => '5', 'rows' => '6'),
      'required' => false
      'data' => "your text here"
      )) 
如果该值是动态的,则改为使用选项进行设置:

->add('post_intro', 'textarea', array(
      'attr' => array('cols' => '5', 'rows' => '6'),
      'required' => false
      'data' => $options["yourData"],
      )) 
然后,您可以在创建表单时从控制器发送数据。控制器:

$yourData = "something" // here you will set what you want to display in the field. 

$form = $this->createForm(YourClass::class, $yourClass, 
        ['yourData' => $yourData]);
->add('post_intro', 'textarea', array(
      'attr' => array('cols' => '5', 'rows' => '6'),
      'required' => false
      'data' => $options["yourData"],
      )) 
$yourData = "something" // here you will set what you want to display in the field. 

$form = $this->createForm(YourClass::class, $yourClass, 
        ['yourData' => $yourData]);