TYPO3 CMS  TYPO3_6-2
SelectElement.php
Go to the documentation of this file.
1 <?php
3 
23 
29  protected $allowedAttributes = array(
30  'class' => '',
31  'disabled' => '',
32  'id' => '',
33  'lang' => '',
34  'multiple' => '',
35  'name' => '',
36  'size' => '',
37  'style' => '',
38  'tabindex' => '',
39  'title' => ''
40  );
41 
47  protected $mandatoryAttributes = array(
48  'name',
49  'id'
50  );
51 
58  public function addElement(\TYPO3\CMS\Form\Domain\Model\Element\AbstractElement $element) {
59  if (
60  !($element instanceof \TYPO3\CMS\Form\Domain\Model\Element\OptionElement)
61  && !($element instanceof \TYPO3\CMS\Form\Domain\Model\Element\OptgroupElement)
62  ) {
63  throw new \InvalidArgumentException('Element type "' . get_class($element) . '" is not supported.', 1442928537);
64  }
65  $element->setParentName($this->getName());
66  $this->elements[] = $element;
67  return $this;
68  }
69 
77  public function setAttribute($attribute, $value) {
78  if (array_key_exists($attribute, $this->allowedAttributes)) {
79  $this->attributes->addAttribute($attribute, $value);
80  }
81  if (
82  $attribute === 'name' && $this->attributes->hasAttribute('multiple') &&
83  $this->attributes->getValue('multiple') === 'multiple' ||
84  $attribute === 'multiple' && $this->attributes->hasAttribute('name')
85  ) {
87  $nameAttribute = $this->attributes->getAttributeObjectByKey('name');
88  $nameAttribute->setAddition('[]');
89  }
90  return $this;
91  }
92 
93 }
addElement(\TYPO3\CMS\Form\Domain\Model\Element\AbstractElement $element)