public function testCanSetMonthFromDateTime()
 {
     $element = new MonthSelectElement();
     $element->setValue(new DateTime('2012-09'));
     $this->assertEquals('2012', $element->getYearElement()->getValue());
     $this->assertEquals('09', $element->getMonthElement()->getValue());
 }
 public function testCanRenderTextDelimiters()
 {
     $element = new MonthSelect('foo');
     $element->setShouldCreateEmptyOption(true);
     $element->setShouldRenderDelimiters(true);
     $markup = $this->helper->__invoke($element, \IntlDateFormatter::LONG, 'pt_BR');
     // pattern === "MMMM 'de' y"
     $this->assertStringMatchesFormat('%a de %a', $markup);
 }
Exemple #3
0
 /**
  * {@inheritDoc}
  */
 public function getInputSpecification()
 {
     $inputSpec = parent::getInputSpecification();
     $inputSpec['required'] = false;
     $inputSpec['filters'][] = ['name' => 'MonthSelect', 'options' => ['null_on_empty' => true]];
     return $inputSpec;
 }
Exemple #4
0
 /**
  * Prepare the form element (mostly used for rendering purposes)
  *
  * @param  FormInterface $form
  * @return mixed
  */
 public function prepareElement(FormInterface $form)
 {
     parent::prepareElement($form);
     $name = $this->getName();
     $this->dayElement->setName($name . '[day]');
 }