/** * Update the tabIndex attribute, in case of changes to tabIndex or disabled * state. * * @return $this */ public function updateTabIndex() { $disabled = $this->isDisabled(); if ($this->tabIndex !== null) { $this->tabIndexed->setAttributes(['tabindex' => $disabled ? -1 : $this->tabIndex, 'aria-disabled' => $disabled ? 'true' : 'false']); } else { $this->tabIndexed->removeAttributes(['tabindex', 'aria-disabled']); } return $this; }
/** * Set title. * * @param string|null $title Title text or null for no title * @return $this */ public function setTitle($title) { $title = $title !== '' ? $title : null; if ($this->title !== $title) { $this->title = $title; if ($title !== null) { $this->titled->setAttributes(['title' => $title]); } else { $this->titled->removeAttributes(['title']); } } return $this; }
/** Tests for {@link Element::setAttributes}. */ public function testSetAttributes() { $e = new Element('img'); $e->setAttributes(['alt' => 'Blue sky', 'id' => 'photo1']); $a = $e->getAttributes(); $this->assertSame(2, count($a), 'Element has incorrect number of attributes.'); $this->assertSame('Blue sky', $a['alt'], 'First attribute value incorrect.'); $this->assertSame('photo1', $a['id'], 'Second attribute value incorrect.'); }
public function getRegistrationForm($entityManager, $user) { $builder = new DoctrineAnnotationBuilder($entityManager); $form = $builder->createForm($user); $form->setHydrator(new DoctrineHydrator($entityManager, 'Access\\Entity\\Access')); $filter = $form->getInputFilter(); $form->remove('UserGroup_id'); $form->remove('isActive'); $form->remove('stQuestion'); $form->remove('stAnswer'); $form->remove('stPicture'); $form->remove('stPasswordSalt'); $form->remove('dtInsert'); $form->remove('stRegistrationToken'); $form->remove('enumEmailConfirmed'); // ... A lot of work of manually building the form $form->add(array('name' => 'stConfirmation', 'attributes' => array('type' => 'password'), 'options' => array('label' => 'Confirm Password'))); $form->add(array('type' => 'Zend\\Form\\Element\\Captcha', 'name' => 'captcha', 'options' => array('label' => 'Please verify you are human', 'captcha' => new \Zend\Captcha\Figlet()))); $send = new Element('submit'); $send->setValue('Register'); // submit $send->setAttributes(array('type' => 'submit')); $form->add($send); // ... return $form; }