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); }
/** * {@inheritDoc} */ public function getInputSpecification() { $inputSpec = parent::getInputSpecification(); $inputSpec['required'] = false; $inputSpec['filters'][] = ['name' => 'MonthSelect', 'options' => ['null_on_empty' => true]]; return $inputSpec; }
/** * 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]'); }