首页 > 解决方案 > 什么是表单变量

问题描述

我在树枝上有这个模板:

{% form_theme form _self %}  

{% block body %}

<div class="container">
    <h1>creer une nouvelle annonce</h1>

    {{ form_start(form) }}

        {{ form_widget(form) }}

        <button type="submit" class="btn btn-primary">créer la nouvelle annonce</button>

    {{ form_end(form, {'render_rest': false}) }}

</div>

{% endblock %}

{% block form_row %}

<pre>
    {{ dump() }}
</pre>
<div class="form-group">
    {{ form_label(form) }}
    {{ form_widget(form) }}
</div>

{% endblock %}

这是我的 chrome 中转储函数的输出:

array:32 [▼
"value" => ""
  "attr" => array:1 [▶]
  "form" => Symfony\Component\Form\FormView {#707 ▶}
  "id" => "ad_title"
  "name" => "title"
  "full_name" => "ad[title]"
  "disabled" => false
  "label" => null
  "label_format" => null
  "multipart" => false
  "block_prefixes" => array:3 [▶]
  "unique_block_prefix" => "_ad_title"
  "row_attr" => []
  "translation_domain" => null
  "label_translation_parameters" => []
  "attr_translation_parameters" => []
  "cache_key" => "_ad_title_text"
  "errors" => Symfony\Component\Form\FormErrorIterator {#708 ▶}
  "valid" => true
  "data" => null
  "required" => true
  "size" => null
  "label_attr" => []
  "help" => null
  "help_attr" => []
  "help_html" => false
  "help_translation_parameters" => []
  "compound" => false
  "method" => "POST"
  "action" => ""
  "submitted" => false
  "app" => Symfony\Bridge\Twig\AppVariable {#277 ▶}
]

截图

form上面转储函数输出的第 4 行中的变量是什么

标签: phptwigsymfony4

解决方案


推荐阅读