public function addSiteEnableCheckbox($event) { $siteSettings = $this->getServiceLocator()->get('Omeka\\SiteSettings'); $form = $event->getParam('form'); $fieldset = new Fieldset('sharing'); $fieldset->setLabel('Sharing'); $enabledMethods = $siteSettings->get('sharing_methods', array()); $fieldset->add(['name' => 'sharing_methods', 'type' => 'multiCheckbox', 'options' => ['label' => 'Enable Sharing module for these methods', 'value_options' => ['fb' => ['label' => 'Facebook', 'value' => 'fb', 'selected' => in_array('fb', $enabledMethods)], 'twitter' => ['label' => 'Twitter', 'value' => 'twitter', 'selected' => in_array('twitter', $enabledMethods)], 'tumblr' => ['label' => 'Tumblr', 'value' => 'tumblr', 'selected' => in_array('tumblr', $enabledMethods)], 'pinterest' => ['label' => 'Pinterest', 'value' => 'pinterest', 'selected' => in_array('pinterest', $enabledMethods)], 'email' => ['label' => 'Email', 'value' => 'email', 'selected' => in_array('email', $enabledMethods)], 'embed' => ['label' => 'Embed codes', 'value' => 'embed', 'selected' => in_array('embed', $enabledMethods)]]], 'attributes' => ['required' => false]]); $form->add($fieldset); }
public function prepare() { if ($this->isPrepared) { return $this; } $email = new Email('email'); $email->setLabel('Email'); $password = new Password('password'); $password->setLabel('P2assword'); $member = new Radio('memberOf'); $member->setValueOptions(array('__model.id__' => '__model.name__')); $memberOfTemplate = new TemplateCollection('memberOfTemplate'); $memberOfTemplate->setTargetElement($member); $memberOf = new Fieldset('memberOfGroup'); $memberOf->setLabel('Member of')->add($memberOfTemplate); $submit = new Submit('register'); $submit->setValue('Register'); $this->add($memberOf)->add($submit); return parent::prepare(); }
/** * Test invoke */ public function testInvoke() { $form = new Form('test_form', array('description' => array('label' => 'form description', 'translatable' => false, 'attributes' => array('class' => 'form-description')))); $fieldset = new Fieldset('test_fieldset', array('description' => array('label' => 'fieldset description', 'translatable' => false))); $text = new Element\Text('test_text', array('description' => 'text description', 'display_group' => 'display group')); $hidden = new Element\Hidden('test_hidden'); $search = new Element\Search('test_search', array('display_group' => 'display group')); $submit = new Element\Submit('test_submit'); $fieldset->setLabel('fieldset label'); $text->setLabel('text label'); $search->setLabel('search label'); $submit->setValue('submit label'); $fieldset->add($text); $fieldset->add($hidden); $fieldset->add($search); $form->add($fieldset); $form->add($submit); $translator = $this->getMock('Zend\\I18n\\Translator\\Translator'); $translator->expects($this->at(1))->method('translate')->with('fieldset label', 'text domain')->will($this->returnValue('fieldset label at text domain')); $translator->expects($this->at(2))->method('translate')->with('display group', 'text domain')->will($this->returnValue('display group at text domain')); $translator->expects($this->at(3))->method('translate')->with('text label', 'text domain')->will($this->returnValue('text label at text domain')); $translator->expects($this->at(4))->method('translate')->with('text description', 'text domain')->will($this->returnValue('text description at text domain')); $translator->expects($this->at(5))->method('translate')->with('search label', 'text domain')->will($this->returnValue('search label at text domain')); $translator->expects($this->at(6))->method('translate')->with('submit label', 'text domain')->will($this->returnValue('submit label at text domain')); $rendered = $this->helper($form, $translator, 'text domain'); $this->assertTag($formMatcher = array('tag' => 'form', 'attributes' => array('name' => 'test_form')), $rendered); $this->assertTag(array('class' => 'form-description description', 'ancestor' => $formMatcher, 'content' => 'form description'), $rendered); $this->assertTag($fieldsetMatcher = array('tag' => 'fieldset', 'ancestor' => $formMatcher, 'attributes' => array('name' => 'test_fieldset')), $rendered); $this->assertTag(array('tag' => 'legend', 'parent' => $fieldsetMatcher, 'content' => 'fieldset label at text domain'), $rendered); $this->assertTag(array('class' => 'description', 'ancestor' => $fieldsetMatcher, 'content' => 'fieldset description'), $rendered); $this->assertTag($displayGroupMatcher = array('tag' => 'fieldset', 'ancestor' => $fieldsetMatcher, 'attributes' => array('class' => 'display-group')), $rendered); $this->assertTag(array('tag' => 'label', 'ancestor' => $displayGroupMatcher, 'content' => 'text label at text domain'), $rendered); $this->assertTag(array('tag' => 'input', 'ancestor' => $displayGroupMatcher, 'attributes' => array('type' => 'text', 'name' => 'test_fieldset[test_text]')), $rendered); $this->assertTag(array('tag' => 'input', 'ancestor' => $fieldsetMatcher, 'attributes' => array('type' => 'hidden', 'name' => 'test_fieldset[test_hidden]')), $rendered); $this->assertTag(array('tag' => 'label', 'ancestor' => $displayGroupMatcher, 'content' => 'search label at text domain'), $rendered); $this->assertTag(array('tag' => 'input', 'ancestor' => $displayGroupMatcher, 'attributes' => array('type' => 'search', 'name' => 'test_fieldset[test_search]')), $rendered); $this->assertTag(array('tag' => 'input', 'ancestor' => $formMatcher, 'attributes' => array('type' => 'submit', 'name' => 'test_submit', 'value' => 'submit label at text domain')), $rendered); }
/** * Builds fieldset with additional properties for the "yearly" repeat picker value. * It returns the built fieldset (used as a child of the "repeat" fieldset). * * @return Fieldset */ public function getRepeatYearlyFieldset() { $repeatYearlyFieldset = new Fieldset(self::YEARLY); $repeatYearlyFieldset->setLabel('Pick date'); $month = new Element\Select('month'); $month->setAttributes(array('class' => 'form-control month pull-left', 'autocomplete' => 'off')); $month->setValueOptions($this->_monthOptions); $repeatYearlyFieldset->add($month); $day = new Element\Number('dayOfMonth'); $day->setValue(1); $day->setAttributes(array('class' => 'form-control input-day pull-left', 'autocomplete' => 'off', 'maxlength' => 2, 'min' => 1, 'max' => 31)); $repeatYearlyFieldset->add($day); return $repeatYearlyFieldset; }
/** * Initialize Server sub form * * @param array $config Configuration * * @return Config */ public function initServer($config) { //Local settings $localeFieldset = new Fieldset('locale'); $localeFieldset->setLabel('Locale'); $locale = new Element\Select('locale'); $locale->setLabel('Server locale')->setLabelAttributes(array('class' => 'required control-label col-lg-2'))->setAttribute('id', 'locale')->setAttribute('class', 'form-control')->setValueOptions($config['locales']); $localeFieldset->add($locale); $this->getInputFilter()->add(array('name' => 'locale', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'locale'); $this->add($localeFieldset); //Mail settings $mailFieldset = new Fieldset('mail'); $mailFieldset->setLabel('Mail'); $mailFrom = new Element\Text('mail_from'); $mailFrom->setLabel('From E-mail')->setLabelAttributes(array('class' => 'required control-label col-lg-2'))->setAttribute('id', 'mail_from')->setAttribute('class', 'form-control'); $mailFieldset->add($mailFrom); $this->getInputFilter()->add(array('name' => 'mail_from_name', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'mail_from_name'); $mailFromName = new Element\Text('mail_from_name'); $mailFromName->setLabel('From name')->setLabelAttributes(array('class' => 'required control-label col-lg-2'))->setAttribute('id', 'mail_from_name')->setAttribute('class', 'form-control'); $mailFieldset->add($mailFromName); $this->getInputFilter()->add(array('name' => 'mail_from', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'mail_from'); $this->add($mailFieldset); //Web settings $webFieldset = new Fieldset('web'); $webFieldset->setLabel('Web'); $forceBackendSsl = new Element\Checkbox('force_backend_ssl'); $forceBackendSsl->setLabel('Force backend SSL')->setLabelAttributes(array('class' => 'required control-label col-lg-2'))->setAttribute('id', 'force_backend_ssl')->setAttribute('class', 'input-checkbox')->setAttribute('id', 'force-backend-ssl'); $webFieldset->add($forceBackendSsl); $this->getInputFilter()->add(array('name' => 'force_backend_ssl', 'required' => false), 'force_backend_ssl'); $forceFrontendSsl = new Element\Checkbox('force_frontend_ssl'); $forceFrontendSsl->setLabel('Force frontend SSL')->setLabelAttributes(array('class' => 'required control-label col-lg-2'))->setAttribute('id', 'force_frontend_ssl')->setAttribute('class', 'input-checkbox')->setAttribute('id', 'force-frontend-ssl'); $webFieldset->add($forceFrontendSsl); $this->getInputFilter()->add(array('name' => 'force_frontend_ssl', 'required' => false), 'force_frontend_ssl'); $pathFields = array('Unsecure backend base path' => 'unsecure_backend_base_path', 'Unsecure frontend base path' => 'unsecure_frontend_base_path', 'Secure backend base path' => 'secure_backend_base_path', 'Secure frontend base path' => 'secure_frontend_base_path', 'Unsecure cdn base path' => 'unsecure_cdn_base_path', 'Secure cdn base path' => 'secure_cdn_base_path'); foreach ($pathFields as $label => $identifier) { $field = new Element\Text($identifier); $field->setLabel($label)->setLabelAttributes(array('class' => 'required control-label col-lg-2'))->setAttribute('id', $identifier)->setAttribute('class', 'form-control'); $webFieldset->add($field); $this->getInputFilter()->add(array('name' => $identifier, 'required' => false, 'validators' => array(array('name' => 'uri'))), $identifier); } $this->add($webFieldset); return $this; }