douzi7219
2016-06-22 11:50
浏览 106
已采纳

在Symfony 2 twig上获取默认日期时间表单

i have some probleme, i would like to have a default value in my datetime twig, i dont want to have the defaut value from BuildForm cause i use it for other twigs.

My add twig

     <div class="form-group">
        {{ form_label(form.Url, "Le URL", {'label_attr': {'class': 'col-sm-4 textTab control-label'}}) }}
        {{ form_errors(form.Url) }}
        <div class="col-sm-6">
          {{ form_widget(form.Url, {'attr': {'class': 'form-control'}}) }}
        </div>
    </div>

    <div class="form-group">
        {{ form_label(form.dateDeLaDemande, "Date de la demande du crawl", {'label_attr': {'class': 'col-sm-4 textTab control-label'}}) }}
        {{ form_errors(form.dateDeLaDemande) }}
        <div class="col-sm-6" style="margin-top: 8px;">
          {{ form_widget(form.dateDeLaDemande, {'attr': {'class': 'col-sm-6'}}) }}
        </div>
    </div>

    <div class="form-group">

        {{ form_label(form.DateDuCrawl, "Date du crawl", {'label_attr': {'class': 'col-sm-4 textTab control-label'}}) }}
        {{ form_errors(form.DateDuCrawl) }}
        <div class="col-sm-6" style="margin-top: 8px;">
          {{ form_widget(form.DateDuCrawl, {'attr': {'class': 'col-sm-6' }}) }}
        </div>
    </div>

And my buildFom

 */
public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
              ->add('site','text')


              ->add('Url','url')
              ->add('dateDeLaDemande','date')
              ->add('DateDuCrawl','date')
              ->add('DateNextCrawl','date')                    
              ->add('faitVP', 'checkbox', array('required' => false))
              ->add('integrerMavec','checkbox', array('required' => false))                    
//            ->add('historique','textarea')
              ->add('historiques', 'collection', array(
                        'type'         => new CategoryType(),
                        'allow_add'    => true,
                        'allow_delete' => true
                      ))
              ->add('save','submit') 
    ;
}

Can some one help me plz ? thanks and sorry about my english :)

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

1条回答 默认 最新

相关推荐 更多相似问题