douruduan8812
2019-01-07 10:25
浏览 7
已采纳

如何在Doctrine中使用Symfony Widgets

I want to use this widget in my datafield:

'widget' => 'single_text',

but i can't insert in my code:

 /**
 * @var string
 *
 * @ORM\Column(name="purchasedate", type="date")
 * @Assert\Range(
 *      min = "2019-01-14",
 *      max = "2019-04-14"
 * )
 * 
 * 
 * @Serializer\SerializedName("purchasedate")
 * @Serializer\Expose()
 * 
 */

private $purchasedate;

How the field is suppose to be

How it's now

How i'm building the form :

  <div class="form-group col-12">
        {{ form_widget(form.user.purchasedate, {'attr': {'class': 'form-control required',
        'placeholder': 'Date d’achat (JJ/MM/AAAA)*', 'maxlength': 13}})}}
        {% if form_errors(form.user.purchasedate) %}<span class="error-form">{{
            form_errors(form.user.purchasedate) }}</span>{% endif %}
    </div>

Controller PatricipationType

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题