I expect that when the page is displayed, it will be entered (type = date). But I get type = text.
<html>
<head></head>
<body>
<input id="test_form_studentdob" class="normal" type="text" placeholder="DD-MM-YYYY" name="test_form[studentdob]">
</body>
</html>
I already tried this:
Any ideas what I can do wrong? thank
Symfony controller fragment:
public function testAction(Request $request) {
$form = $this->createForm(new TestFormType());
$form->handleRequest($request);
return $this->render(
"AppBundle:SelfService:TestForm.html.twig"
, array("form" => $form->createView())
);
}
Symfony Form Type Type:
<?php
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType
, Symfony\Component\Form\FormBuilderInterface
, Symfony\Component\OptionsResolver\OptionsResolverInterface;
class TestFormType extends AbstractType {
public function setDefaultOptions(OptionsResolverInterface $resolver) {
$resolver->setDefaults(
array(
"attr" => array(
"id" => "testform"
)
)
);
}
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder
->setMethod("GET")
->add(
"studentdob"
, "date"
, array(
"attr" => array(
"class" => "normal"
, "placeholder" => "DD-MM-YYYY"
)
, "format" => "dd-MM-yyyy"
, "required" => false
, "widget" => "single_text"
)
);
}
}
This is my Twig template:
{% block body %}
{{ form_widget(form.studentdob) }}
{% endblock %}
source
share