Ejemplo n.º 1
0
 /** @test */
 public function it_should_process_an_element_with_options()
 {
     $languages = new Select('languages', [1 => 'PHP', 2 => 'Scala']);
     $languagesView = $languages->buildView();
     $options = ['attr' => ['class' => 'js-update'], 'label' => 'Languages', 'label_attr' => ['class' => 'required-label'], 'options' => ['custom_option' => 'custom_value']];
     $processedOptions = $this->options->process($languagesView, $options);
     $this->assertEquals(['element' => $languagesView, 'isValid' => true, 'attr' => ['class' => 'js-update', 'name' => 'languages'], 'options' => ['custom_option' => 'custom_value'], 'label' => 'Languages', 'label_attr' => ['class' => 'required-label']], $processedOptions);
 }
Ejemplo n.º 2
0
 function it_should_render_a_form_row(BlockOptions $blockOptions, FormTheme $theme, Template $template)
 {
     $username = new Text('username');
     $username->setValue('john.doe');
     $username->setMessages(['User "john.doe" does not exist.']);
     $options = ['attr' => ['class' => 'inline-element'], 'label' => 'Username', 'label_attr' => ['class' => 'inline-label']];
     $usernameView = $username->buildView();
     $processedOptions = ['element' => $usernameView, 'isValid' => $usernameView->isValid, 'attr' => $usernameView->attributes + $options['attr'], 'options' => [], 'label' => $options['label'], 'label_attr' => $options['label_attr']];
     $theme->loadTemplateFor($usernameView->rowBlock)->willReturn($template);
     $theme->blocks()->willReturn([]);
     $blockOptions->process($usernameView, $options)->willReturn($processedOptions);
     $this->renderRow($usernameView, $options);
     $template->displayBlock($usernameView->rowBlock, $processedOptions, [])->shouldHaveBeenCalled();
 }
Ejemplo n.º 3
0
 /**
  * @param ElementView $element
  * @param array $options {
  *     @var array   $attr       This element HTML attributes
  *     @var string  $label      The display name for this element
  *     @var array   $label_attr The HTML attributes for this element's label
  * }
  * @return string
  */
 public function renderRow(ElementView $element, array $options = [])
 {
     return $this->renderBlock($element->rowBlock, $this->options->process($element, $options));
 }