Esempio n. 1
0
 public function __construct($name = 'register-form', CaptchaOptions $options, $role = 'recruiter')
 {
     parent::__construct($name, []);
     $this->setAttribute('data-handle-by', 'native');
     $this->setAttribute('class', 'form-horizontal');
     $fieldset = new Fieldset('register');
     $fieldset->setOptions(array('renderFieldset' => true));
     $fieldset->add(array('type' => 'text', 'name' => 'name', 'options' => array('label' => 'Name')));
     $fieldset->add(array('type' => 'email', 'name' => 'email', 'options' => array('label' => 'Email'), 'attributes' => ['required' => true]));
     $fieldset->add(array('name' => 'role', 'type' => 'hidden', 'attributes' => array('value' => $role)));
     $this->add($fieldset);
     $mode = $options->getMode();
     if (in_array($mode, [CaptchaOptions::RE_CAPTCHA, CaptchaOptions::IMAGE])) {
         if ($mode == CaptchaOptions::IMAGE) {
             $captcha = new Image($options->getImage());
         } elseif ($mode == CaptchaOptions::RE_CAPTCHA) {
             $captcha = new ReCaptcha($options->getReCaptcha());
         }
         if (!empty($captcha)) {
             $this->add(array('name' => 'captcha', 'options' => array('label' => 'Are you human?', 'captcha' => $captcha), 'type' => 'Zend\\Form\\Element\\Captcha'));
         }
     }
     $buttons = new ButtonsFieldset('buttons');
     $buttons->add(array('type' => 'submit', 'name' => 'button', 'attributes' => array('type' => 'submit', 'value' => 'Register', 'class' => 'btn btn-primary')));
     $this->add(array('name' => 'csrf', 'type' => 'csrf', 'options' => array('csrf_options' => array('salt' => str_replace('\\', '_', __CLASS__), 'timeout' => 3600))));
     $this->add($buttons);
 }
Esempio n. 2
0
 public function __construct($name = 'register-form', $options = array())
 {
     parent::__construct($name, $options);
     $this->setAttribute('data-handle-by', 'native');
     $this->setAttribute('class', 'form-horizontal');
     $fieldset = new Fieldset('register');
     $fieldset->setOptions(array('renderFieldset' => true));
     $fieldset->add(array('type' => 'text', 'name' => 'name', 'options' => array('label' => 'Name')));
     $fieldset->add(array('type' => 'email', 'name' => 'email', 'options' => array('label' => 'Email')));
     $fieldset->add(array('name' => 'role', 'type' => 'hidden', 'attributes' => array('value' => User::ROLE_RECRUITER)));
     $this->add($fieldset);
     if (($captchaOptions = $this->getOption('captcha')) && !empty($captchaOptions['use'])) {
         if ($captchaOptions['use'] === 'image' && !empty($captchaOptions['image'])) {
             $captcha = new Image($captchaOptions['image']);
         } elseif ($captchaOptions['use'] === 'reCaptcha' && !empty($captchaOptions['reCaptcha'])) {
             $captcha = new ReCaptcha($captchaOptions['reCaptcha']);
         }
         if (!empty($captcha)) {
             $this->add(array('name' => 'captcha', 'options' => array('label' => 'Are you human?', 'captcha' => $captcha), 'type' => 'Zend\\Form\\Element\\Captcha'));
         }
     }
     $buttons = new ButtonsFieldset('buttons');
     $buttons->add(array('type' => 'submit', 'name' => 'button', 'attributes' => array('type' => 'submit', 'value' => 'Register', 'class' => 'btn btn-primary')));
     $this->add(array('name' => 'csrf', 'type' => 'csrf', 'options' => array('csrf_options' => array('salt' => str_replace('\\', '_', __CLASS__), 'timeout' => 3600))));
     $this->add($buttons);
 }
Esempio n. 3
0
 public function addButtons()
 {
     $fieldSet = new Fieldset('buttons');
     $fieldSet->setAttributes(array('class' => 'dots-form-buttons'));
     $fieldSet->add(array('name' => 'cancel', 'options' => array('label' => 'Cancel'), 'attributes' => array('type' => 'button', 'class' => 'btn', 'data-action' => 'link_cancel')));
     $fieldSet->add(array('name' => 'save', 'options' => array('label' => 'Save'), 'attributes' => array('type' => 'button', 'class' => 'btn btn-primary', 'data-action' => 'link_save')));
     $this->add($fieldSet);
 }
Esempio n. 4
0
 /**
  * Prepare elements for configuration
  *
  * @return void
  */
 public function prepareConfig()
 {
     $options = $this->getModel()->getConfig();
     $fieldset = new Fieldset('config');
     $language = new Element\Select('language');
     $language->setLabel('Language')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('class', 'form-control col-lg-10')->setValueOptions($this->getModel()->getLanguages())->setValue($options['language']);
     $fieldset->add($language);
     $ga = new Element\Text('data_ga_property_id');
     $ga->setLabel('Google Analytics property ID')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('class', 'form-control col-lg-10')->setValue($options['data_ga_property_id']);
     $fieldset->add($ga);
     $showOnDashboard = new Element\Checkbox('show_stats');
     $showOnDashboard->setLabel('Show stats on dashboard')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('id', 'show_stats')->setAttribute('class', 'input-checkbox')->setValue($options['show_stats']);
     $fieldset->add($showOnDashboard);
     $profileId = new Element\Text('profile_id');
     $profileId->setLabel('AddThis Profile ID')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('class', 'form-control col-lg-10')->setValue($options['profile_id']);
     $fieldset->add($profileId);
     $username = new Element\Text('username');
     $username->setLabel('AddThis Username')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('class', 'form-control col-lg-10')->setValue($options['username']);
     $fieldset->add($username);
     $password = new Element\Password('password');
     $password->setLabel('AddThis Password')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('class', 'form-control col-lg-10')->setValue($options['password']);
     $fieldset->add($password);
     $dataTrackClickback = new Element\Checkbox('data_track_clickback');
     $dataTrackClickback->setLabel('Track clickback')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('id', 'data_track_clickback')->setAttribute('class', 'input-checkbox')->setValue($options['data_track_clickback']);
     $fieldset->add($dataTrackClickback);
     $dataTrackAddressbar = new Element\Checkbox('data_track_addressbar');
     $dataTrackAddressbar->setLabel('Track adressbar')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('id', 'data_track_addressbar')->setAttribute('class', 'input-checkbox')->setValue($options['data_track_addressbar']);
     $fieldset->add($dataTrackAddressbar);
     $jsonConfig = new Element\Textarea('config_json');
     $jsonConfig->setLabel('Json config')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('class', 'form-control col-lg-10')->setValue($options['config_json']);
     $fieldset->add($jsonConfig);
     $this->add($fieldset);
     $this->getInputFilter()->add(array('type' => 'Zend\\InputFilter\\InputFilter', 'language' => array('name' => 'language', 'required' => true), 'data_ga_property_id' => array('name' => 'data_ga_property_id', 'required' => false), 'profile_id' => array('name' => 'profile_id', 'required' => false, 'validators' => array(array('name' => 'Callback', 'options' => array('messages' => array(\Zend\Validator\Callback::INVALID_VALUE => 'Can not connect to addthis api'), 'callback' => function ($value, $context = array()) {
         if (empty($context['username']) or empty($context['password'])) {
             return false;
         }
         return true;
     })))), 'show_stats' => array('name' => 'show_stats', 'required' => false), 'password' => array('name' => 'password', 'required' => false, 'validators' => array(array('name' => 'Callback', 'options' => array('messages' => array(\Zend\Validator\Callback::INVALID_VALUE => 'Can not connect to addthis api'), 'callback' => function ($value, $context = array()) {
         if (empty($context['username']) or empty($context['profile_id'])) {
             return false;
         }
         return true;
     })))), 'username' => array('name' => 'username', 'required' => false, 'validators' => array(array('name' => 'Callback', 'options' => array('messages' => array(\Zend\Validator\Callback::INVALID_VALUE => 'Can not connect to addthis api'), 'callback' => function ($value, $context = array()) {
         $client = new Client('https://api.addthis.com/analytics/1.0/pub/shares.json', array('sslverifypeer' => false));
         $client->setParameterGet(array('username' => $context['username'], 'password' => $context['password'], 'pubid' => $context['profile_id']));
         try {
             $response = $client->send();
             if ($response->isSuccess() == 200) {
                 return true;
             }
         } catch (\Exception $e) {
             //don't care
         }
         return false;
     })))), 'data_track_clickback' => array('name' => 'data_track_clickback', 'required' => false), 'data_track_addressbar' => array('name' => 'data_track_addressbar', 'required' => false), 'json_config' => array('name' => 'json_config', 'required' => false)), 'config');
 }
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $form = new Form();
     $form->setName('login-form');
     $form->add(array('type' => 'hidden', 'name' => 'ref'));
     $fieldset = new Fieldset();
     $fieldset->add(array('name' => 'login', 'options' => array('label' => 'Login name', 'description' => 'Provide your login key (e.g. email adress)')));
     $fieldset->add(array('type' => 'password', 'name' => 'credential', 'options' => array('label' => 'Password')));
     $form->add($fieldset);
     $form->add($this->forms->get('DefaultButtonsFieldset'));
 }
Esempio n. 6
0
 public function __construct($name = 'login-form', $options = array())
 {
     parent::__construct($name, $options);
     $this->setAttribute('data-handle-by', 'native');
     $this->setAttribute('class', 'form-inline');
     $fieldset = new Fieldset('credentials');
     $fieldset->setOptions(array('renderFieldset' => true));
     $fieldset->add(array('name' => 'login', 'options' => array('id' => 'login', 'label' => 'Login name')));
     $fieldset->add(array('type' => 'password', 'name' => 'credential', 'options' => array('id' => 'credential', 'label' => 'Password')));
     $this->add($fieldset);
     $buttons = new \Core\Form\ButtonsFieldset('buttons');
     $buttons->add(array('type' => 'submit', 'name' => 'button', 'attributes' => array('id' => 'submit', 'type' => 'submit', 'value' => 'login', 'class' => 'btn btn-primary')));
     $this->add($buttons);
 }
 public function init()
 {
     $this->setName('login-form');
     $this->setAttribute('data-handle-by', 'native');
     $fieldset = new Fieldset('credentials');
     //$fieldset->setLabel('Enter your credentials');
     $fieldset->setOptions(array('renderFieldset' => true));
     $fieldset->add(array('name' => 'login', 'options' => array('label' => 'Login name')));
     $fieldset->add(array('type' => 'password', 'name' => 'credential', 'options' => array('label' => 'Password')));
     $this->add($fieldset);
     $buttons = new \Core\Form\ButtonsFieldset('buttons');
     $buttons->add(array('type' => 'submit', 'name' => 'button', 'attributes' => array('id' => 'submit', 'type' => 'submit', 'value' => 'login', 'class' => 'btn btn-primary')));
     $this->add($buttons);
 }
Esempio n. 8
0
 /**
  * Class constructor
  */
 public function __construct()
 {
     parent::__construct();
     $this->setAttribute('method', 'get');
     $this->setAttribute('class', 'form-horizontal');
     for ($i = 0; $i <= 2; $i++) {
         $filter = new Fieldset('selection' . $i);
         $filter->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'in', 'options' => ['value_options' => $this->inOptions], 'attributes' => ['label' => 'search']]);
         $filter->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'selection', 'attributes' => ['label' => 'search', 'class' => 'form-control', 'id' => "search", 'placeholder' => _("txt-site-search")]]);
         $this->add($filter);
     }
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'cancel', 'attributes' => ['class' => "btn btn-danger", 'value' => _("txt-cancel")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-submit")]]);
 }
Esempio n. 9
0
 /**
  * @param GeneralService $mailingService
  */
 public function __construct(GeneralService $mailingService)
 {
     parent::__construct();
     $this->setAttribute('method', 'get');
     $this->setAttribute('action', '');
     $filterFieldset = new Fieldset('filter');
     $filterFieldset->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'search', 'attributes' => ['class' => 'form-control', 'placeholder' => _('txt-search')]]);
     $yesNo = [1 => 'YES', 0 => 'NO'];
     $filterFieldset->add(['type' => 'Zend\\Form\\Element\\Radio', 'name' => 'eu', 'options' => ['value_options' => $yesNo, 'inline' => true], 'attributes' => ['label' => _("txt-eu")]]);
     $filterFieldset->add(['type' => 'Zend\\Form\\Element\\Radio', 'name' => 'eureka', 'options' => ['value_options' => $yesNo, 'inline' => true], 'attributes' => ['label' => _("txt-eureka")]]);
     $filterFieldset->add(['type' => 'Zend\\Form\\Element\\Radio', 'name' => 'itac', 'options' => ['value_options' => $yesNo, 'inline' => true], 'attributes' => ['label' => _("txt-itac-form-label")]]);
     $this->add($filterFieldset);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['id' => 'submit', 'class' => 'btn btn-primary', 'value' => _('txt-filter')]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'clear', 'attributes' => ['id' => 'cancel', 'class' => 'btn btn-warning', 'value' => _('txt-cancel')]]);
 }
 /**
  * @outputBuffering disabled
  */
 public function testCanRenderFieldsets()
 {
     $this->expectOutputRegex('/<form(.*)<fieldset(.*)<\\/fieldset>(.*)<fieldset(.*)<\\/fieldset>(.*)<\\/form>/');
     $form = new NetsensiaForm();
     $form->addHidden('test1', 'testvalue');
     $hidden = new Element\Hidden('asdasd');
     $hidden->setValue('123');
     $form->add($hidden);
     $element1 = new Text('testelement1');
     $element1->setLabel('Test Element');
     $element1->setAttribute('icon', 'pencil');
     $element2 = new Text('testelement2');
     $element2->setLabel('Test Element 2');
     $element2->setAttribute('icon', 'pencil');
     $fieldset1 = new Fieldset('testfieldset1');
     $fieldset1->add($element1);
     $fieldset2 = new Fieldset('testfieldset2');
     $fieldset2->add($element2);
     $form->add($fieldset1);
     $form->add($fieldset2);
     $helpers = new HelperPluginManager();
     $helpers->setService('formElement', new FormElement());
     $view = new PhpRenderer();
     $view->setHelperPluginManager($helpers);
     $viewHelper = new BootstrapForm();
     $viewHelper->setView($view);
     $viewHelper($form, 'testform', '/');
 }
 /**
  * @see \Zend\Form\Form::add
  *
  * @param array|\Traversable|\Zend\Form\ElementInterface $elementOrFieldset
  * @param array $flags
  * @throws \Exception
  * @return $this
  *
  * @author Alaa Al-Maliki <*****@*****.**>
  */
 public function add($elementOrFieldset, array $flags = [])
 {
     if (array_key_exists('renderer', $elementOrFieldset)) {
         $renderer = isset($elementOrFieldset['renderer']) ? $elementOrFieldset['renderer'] : '';
         if (is_string($renderer) && !class_exists($renderer)) {
             throw new \Exception("Class: " . $renderer . " is not defined.");
         }
         if (!is_object($renderer)) {
             $renderer = '\\' . $renderer;
             $rendererClass = new $renderer();
         } else {
             $rendererClass = $renderer;
         }
         if ($rendererClass instanceof Select) {
             $elementOrFieldset['type'] = get_class($rendererClass);
         } else {
             $elementOrFieldset['type'] = 'Zend\\Form\\Element\\Select';
         }
         if (array_key_exists('renderer_label', $elementOrFieldset)) {
             $label = isset($elementOrFieldset['renderer_label']) ? $elementOrFieldset['renderer_label'] : '';
             if ($label) {
                 $elementOrFieldset['options']['label'] = $label;
             }
         }
         $options = method_exists($rendererClass, 'toOptionArray') ? $rendererClass->toOptionArray() : array();
         if (!is_array($options)) {
             $options = array();
         }
         $elementOrFieldset['options']['value_options'] = $options;
     }
     return parent::add($elementOrFieldset, $flags);
 }
Esempio n. 12
0
 public function populateFieldset()
 {
     $this->fieldset->add(new Element('foo'));
     $this->fieldset->add(new Element('bar'));
     $this->fieldset->add(new Element('baz'));
     $subFieldset = new Fieldset('foobar');
     $subFieldset->add(new Element('foo'));
     $subFieldset->add(new Element('bar'));
     $subFieldset->add(new Element('baz'));
     $this->fieldset->add($subFieldset);
     $subFieldset = new Fieldset('barbaz');
     $subFieldset->add(new Element('foo'));
     $subFieldset->add(new Element('bar'));
     $subFieldset->add(new Element('baz'));
     $this->fieldset->add($subFieldset);
 }
Esempio n. 13
0
 /**
  * Load upload prevalue editor
  *
  * @return string
  */
 public function load()
 {
     $parameters = $this->getConfig();
     $elements = array();
     $optionsValues = !empty($parameters['options']) ? $parameters['options'] : array();
     $fieldset = new Fieldset('Available options');
     $element = new Element\MultiCheckbox('options');
     $element->setAttribute('selected', $optionsValues);
     $element->setAttribute('class', 'input-checkbox');
     $element->setValueOptions(array(array('value' => 'maxNumberOfFiles', 'label' => 'Is multiple', 'selected' => empty($optionsValues['maxNumberOfFiles']) ? false : true)));
     $fieldset->add($element);
     $elements[] = $fieldset;
     $element = new Element\MultiCheckbox('mime_list');
     $mimeList = array('image/gif', 'image/jpeg', 'image/png', 'image/tiff', 'image/svg+xml', 'text/css', 'text/csv', 'text/html', 'text/javascript', 'text/plain', 'text/xml', 'video/mpeg', 'video/mp4', 'video/quicktime', 'video/x-ms-wmv', 'video/x-msvideo', 'video/x-flv', 'audio/mpeg', 'audio/x-ms-wma', 'audio/vnd.rn-realaudio', 'audio/x-wav');
     $options = array();
     foreach ($mimeList as $mime) {
         $options[] = array('value' => $mime, 'label' => $mime, 'selected' => !in_array($mime, empty($parameters['mime_list']) ? array() : $parameters['mime_list']) ? false : true);
     }
     $element->setValueOptions($options);
     $element->setAttribute('class', 'input-checkbox');
     $fieldset = new Fieldset('Mime list');
     $fieldset->add($element);
     $elements[] = $fieldset;
     return $this->addPath(__DIR__)->render('upload-prevalue.phtml', array('elements' => $elements));
 }
Esempio n. 14
0
 public function addElements()
 {
     $fieldset = new Fieldset('fieldset');
     // File Input
     $file = new Element\File('file');
     $file->setLabel('Multi-File Input 1')->setAttributes(array('multiple' => true));
     $fieldset->add($file);
     // Text Input
     $text = new Element\Text('text');
     $text->setLabel('Text Entry');
     $fieldset->add($text);
     $this->add($fieldset);
     // File Input 2
     $file2 = new Element\File('file2');
     $file2->setLabel('Multi-File Input 2')->setAttributes(array('multiple' => true));
     $this->add($file2);
 }
Esempio n. 15
0
 public function __construct()
 {
     $inputFilterForm = new InputFilter();
     parent::__construct('form');
     $this->setInputFilter($inputFilterForm);
     $name = new Element('name');
     $name->setLabel('Your name');
     $name->setAttributes(array('type' => 'text'));
     $inputFilterForm->add(array('name' => 'name', 'required' => true, 'validators' => array(array('name' => 'Zend\\Validator\\NotEmpty'))));
     $email = new Element('email');
     $email->setLabel('Your email');
     $email->setAttributes(array('type' => 'text'));
     $inputFilterForm->add(array('name' => 'email', 'required' => true, 'validators' => array(array('name' => 'Zend\\Validator\\EmailAddress'))));
     $photo = new Element('photo');
     $photo->setLabel('Your photo');
     $photo->setAttributes(array('type' => 'file'));
     $inputFilterFieldset = new InputFilter();
     // ---------- FieldsetsElements ----------
     $username = new Element('username');
     $username->setLabel('Your username');
     $username->setAttributes(array('type' => 'text'));
     $inputFilterFieldset->add(array('name' => 'username', 'required' => true, 'validators' => array(array('name' => 'Zend\\Validator\\NotEmpty'))));
     $inputFilterFieldset->add(array('name' => 'password', 'required' => true, 'validators' => array(array('name' => 'Zend\\Validator\\NotEmpty'))));
     $password = new Element('password');
     $password->setLabel('Your password');
     $password->setAttributes(array('type' => 'password'));
     $vpassword = new Element('verify_password');
     $vpassword->setLabel('Verify your password');
     $vpassword->setAttributes(array('type' => 'password'));
     // ---------- FieldsetsElements ----------
     $fieldsetCredential = new Fieldset('id_credential');
     $fieldsetCredential->add($username);
     $fieldsetCredential->add($password);
     $fieldsetCredential->add($vpassword);
     $inputFilterForm->add($inputFilterFieldset, 'id_credential');
     $submit = new Element('submit');
     $submit->setAttributes(array('value' => 'ENVIAR', 'type' => 'submit'));
     // ---------- Formulario ----------
     $this->setHydrator(new \Zend\Stdlib\Hydrator\ClassMethods());
     $this->add($name);
     $this->add($email);
     $this->add($photo);
     $this->add($fieldsetCredential);
     $this->add($submit);
 }
Esempio n. 16
0
 /**
  * SelectionFilter constructor.
  * @param SelectionService $selectionService
  */
 public function __construct(SelectionService $selectionService)
 {
     parent::__construct();
     $this->setAttribute('method', 'get');
     $this->setAttribute('action', '');
     $filterFieldset = new Fieldset('filter');
     $filterFieldset->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'search', 'attributes' => ['class' => 'form-control', 'placeholder' => _('txt-search')]]);
     $tags = [];
     foreach ($selectionService->findTags() as $tag) {
         if (!empty($tag['tag'])) {
             $tags[$tag['tag']] = $tag['tag'];
         }
     }
     $filterFieldset->add(['type' => 'Zend\\Form\\Element\\MultiCheckbox', 'name' => 'tags', 'options' => ['value_options' => $tags, 'inline' => true], 'attributes' => ['label' => _("txt-filter-on-tags")]]);
     $this->add($filterFieldset);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['id' => 'submit', 'class' => 'btn btn-primary', 'value' => _('txt-filter')]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'clear', 'attributes' => ['id' => 'cancel', 'class' => 'btn btn-warning', 'value' => _('txt-cancel')]]);
 }
Esempio n. 17
0
 /**
  * @param Doa[] $doa
  */
 public function __construct(array $doa, ContactService $contactService)
 {
     parent::__construct();
     $this->setAttribute('method', 'post');
     $this->setAttribute('class', 'form-horizontal');
     /**
      * Create a fieldSet per DOA (and affiliation)
      */
     foreach ($doa as $doa) {
         $affiliationFieldset = new Fieldset('affiliation_' . $doa->getAffiliation()->getId());
         $contactService->findContactsInAffiliation($doa->getAffiliation());
         $affiliationFieldset->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'contact', 'options' => ['value_options' => $contactService->toFormValueOptions(), 'label' => _("txt-contact-name")], 'attributes' => ['class' => 'form-control', 'id' => 'contact-' . $doa->getId(), 'required' => true]]);
         $affiliationFieldset->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'dateSigned', 'attributes' => ['class' => 'form-control', 'id' => 'dateSigned-' . $doa->getId(), 'required' => true]]);
         $this->add($affiliationFieldset);
     }
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-update")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'cancel', 'attributes' => ['class' => "btn btn-warning", 'value' => _("txt-cancel")]]);
 }
Esempio n. 18
0
File: Page.php Progetto: nhebi/cms
 public function getButtonFieldset()
 {
     // Fieldset for buttons
     $buttons = new Fieldset('buttons');
     $buttons->setAttribute('class', 'well well-small');
     // Add the save button
     $save = new Element\Submit('submit');
     $save->setValue('Save');
     $save->setAttribute('class', 'btn btn-primary');
     $buttons->add($save);
     // Add the delete button
     $delete = new Element\Submit('delete');
     $delete->setValue('Delete');
     $delete->setAttribute('class', 'btn btn-danger');
     $delete->setAttribute('onClick', "return confirm('Are you sure?')");
     $buttons->add($delete);
     return $buttons;
 }
 /**
  * Produce a form element.
  *
  * @param Affiliation    $affiliation
  * @param ProjectService $projectService
  */
 public function __construct(Affiliation $affiliation, ProjectService $projectService)
 {
     parent::__construct($affiliation->getId());
     foreach ($projectService->parseEditYearRange() as $year) {
         $fieldSet = new Fieldset($year);
         $fieldSet->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'cost', 'attributes' => ['class' => 'form-control cost-input year-' . $year, 'label' => 'cost', 'placeholder' => _("txt-cost")]]);
         $this->add($fieldSet);
     }
 }
Esempio n. 20
0
 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);
 }
Esempio n. 21
0
 /**
  * @param GeneralService $mailingService
  */
 public function __construct(GeneralService $mailingService)
 {
     parent::__construct();
     $this->setAttribute('method', 'get');
     $this->setAttribute('action', '');
     $filterFieldset = new Fieldset('filter');
     $filterFieldset->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'search', 'attributes' => ['class' => 'form-control', 'placeholder' => _('txt-search')]]);
     $this->add($filterFieldset);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['id' => 'submit', 'class' => 'btn btn-primary', 'value' => _('txt-filter')]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'clear', 'attributes' => ['id' => 'cancel', 'class' => 'btn btn-warning', 'value' => _('txt-cancel')]]);
 }
Esempio n. 22
0
 public function addSubmissionsFieldset($name = 'submissions', $submissions = array())
 {
     $submissionsFieldset = new Fieldset($name, ['use_as_base_fieldset' => false]);
     if ($submissions) {
         foreach ($submissions as $i => $submission) {
             foreach ($submission as $field => $value) {
                 $submissionsFieldset->add(array('name' => "{$i}[{$field}]", 'attributes' => array('value' => $value, 'type' => 'hidden')));
             }
         }
     }
     $this->add($submissionsFieldset);
     return $submissionsFieldset;
 }
Esempio n. 23
0
 public function addLeadFieldset($name = 'leads', $leadData = array())
 {
     $leadAttributeValuesFieldset = new Fieldset($name, ['use_as_base_fieldset' => false]);
     if ($leadData) {
         foreach ($leadData as $i => $lead) {
             foreach ($lead as $field => $value) {
                 $leadAttributeValuesFieldset->add(array('name' => "{$i}[{$field}]", 'attributes' => array('value' => $value, 'type' => 'hidden')));
             }
         }
     }
     $this->add($leadAttributeValuesFieldset);
     return $leadAttributeValuesFieldset;
 }
Esempio n. 24
0
 /**
  * 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);
 }
 /**
  * Class constructor.
  *
  * @param ProjectService     $projectService
  * @param WorkpackageService $workpackageService
  */
 public function __construct(ProjectService $projectService, WorkpackageService $workpackageService)
 {
     parent::__construct();
     $this->setAttribute('method', 'post');
     $this->setAttribute('class', 'form-horizontal');
     $fieldSet = new Fieldset('effortPerAffiliationAndYear');
     foreach ($workpackageService->findWorkpackageByProjectAndWhich($projectService->getProject()) as $workpackage) {
         $workpackageFieldSet = new EffortPerWorkpackageAndAffiliationFieldset($workpackage, $projectService);
         $fieldSet->add($workpackageFieldSet);
     }
     $fieldSet->setUseAsBaseFieldset(true);
     $this->add($fieldSet);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-update-planned-versus-spent")]]);
 }
Esempio n. 26
0
 /**
  * Class constructor.
  */
 public function __construct(ProjectService $projectService)
 {
     parent::__construct();
     $this->setAttribute('method', 'post');
     $this->setAttribute('class', 'form-horizontal');
     $valueChainFieldSet = new Fieldset('affiliation');
     foreach ($projectService->getAffiliation() as $affiliationService) {
         $fieldSet = new Fieldset($affiliationService->getAffiliation()->getId());
         $fieldSet->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'valueChain', 'options' => ['label' => sprintf(_("%s from %s"), $affiliationService->getAffiliation()->getOrganisation(), $affiliationService->getAffiliation()->getOrganisation()->getCountry())], 'attributes' => ['class' => 'form-control', 'placeholder' => sprintf(_("Posistion of %s on the value chain"), $affiliationService->getAffiliation()->getOrganisation(), $affiliationService->getAffiliation()->getOrganisation()->getCountry())]]);
         $valueChainFieldSet->add($fieldSet);
     }
     $this->add($valueChainFieldSet);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-update-value-chain")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'cancel', 'attributes' => ['class' => "btn btn-warning", 'value' => _("txt-cancel")]]);
 }
Esempio n. 27
0
 /**
  * @param Nda[]          $ndas
  * @param ContactService $contactService
  */
 public function __construct(array $ndas, ContactService $contactService)
 {
     parent::__construct();
     $this->setAttribute('method', 'post');
     $this->setAttribute('class', 'form-horizontal');
     /**
      * Create a fieldSet per NDA (and program)
      */
     foreach ($ndas as $nda) {
         $ndaFieldset = new Fieldset('nda_' . $nda->getId());
         $ndaFieldset->add(['type' => 'Zend\\Form\\Element\\Date', 'name' => 'dateSigned', 'attributes' => ['class' => 'form-control', 'id' => 'dateSigned-' . $nda->getId(), 'required' => true]]);
         $this->add($ndaFieldset);
     }
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-update")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'cancel', 'attributes' => ['class' => "btn btn-warning", 'value' => _("txt-cancel")]]);
 }
 /**
  * @param OrganisationService $organisationService
  */
 public function __construct(OrganisationService $organisationService)
 {
     parent::__construct();
     $this->setAttribute('method', 'get');
     $this->setAttribute('action', '');
     $filterFieldset = new Fieldset('filter');
     $filterFieldset->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'search', 'attributes' => ['class' => 'form-control', 'placeholder' => _('txt-search')]]);
     $types = [];
     foreach ($organisationService->findAll('type') as $type) {
         $types[$type->getId()] = $type->getType();
     }
     $filterFieldset->add(['type' => 'Zend\\Form\\Element\\MultiCheckbox', 'name' => 'type', 'options' => ['inline' => true, 'value_options' => $types], 'attributes' => ['label' => _("txt-organisation-type")]]);
     $filterFieldset->add(['type' => 'Zend\\Form\\Element\\MultiCheckbox', 'name' => 'options', 'options' => ['inline' => true, 'value_options' => [1 => _("txt-active-in-project")]], 'attributes' => ['label' => _("txt-options-type")]]);
     $filterFieldset->add(['type' => 'Zend\\Form\\Element\\MultiCheckbox', 'name' => 'vatStatus', 'options' => ['inline' => true, 'value_options' => Financial::getVatStatusTemplates()], 'attributes' => ['label' => _("txt-vat-status")]]);
     $filterFieldset->add(['type' => 'Zend\\Form\\Element\\MultiCheckbox', 'name' => 'omitContact', 'options' => ['inline' => true, 'value_options' => Financial::getOmitContactTemplates()], 'attributes' => ['label' => _("txt-omit-contact")]]);
     $filterFieldset->add(['type' => 'Zend\\Form\\Element\\MultiCheckbox', 'name' => 'requiredPurchaseOrder', 'options' => ['inline' => true, 'value_options' => Financial::getRequiredPurchaseOrderTemplates()], 'attributes' => ['label' => _("txt-required-purchase-order")]]);
     $filterFieldset->add(['type' => 'Zend\\Form\\Element\\MultiCheckbox', 'name' => 'email', 'options' => ['inline' => true, 'value_options' => Financial::getEmailTemplates()], 'attributes' => ['label' => _("txt-email")]]);
     $this->add($filterFieldset);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['id' => 'submit', 'class' => 'btn btn-primary', 'value' => _('txt-filter')]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'clear', 'attributes' => ['id' => 'cancel', 'class' => 'btn btn-warning', 'value' => _('txt-cancel')]]);
 }
 public function testElementInAFieldsetForSomeModel()
 {
     $element = $this->getMoneyFieldset();
     $element->init();
     $fieldset = new Fieldset('hasMoneyElementFieldset');
     $fieldset->add($element, ['name' => 'price']);
     $fieldset->setHydrator(new ClassMethods());
     $fieldset->setUseAsBaseFieldset(true);
     $form = new Form();
     $form->add($fieldset);
     // todo: can't load this
     $form->bind(new HasMoneyPropertyModel());
     $data = ['hasMoneyElementFieldset' => ['price' => ['amount' => '500.25', 'currency' => 'BRL']]];
     $form->setData($data);
     $this->assertTrue($form->isValid());
     $amountValue = $form->get('hasMoneyElementFieldset')->get('price')->get('amount')->getValue();
     $currencyValue = $form->get('hasMoneyElementFieldset')->get('price')->get('currency')->getValue();
     $object = $form->getData();
     $this->assertSame('500.25', $amountValue);
     $this->assertSame('BRL', $currencyValue);
     $this->assertInstanceOf(Money::class, $object->getPrice());
     $this->assertSame(50025, $object->getPrice()->getAmount());
     $this->assertSame('BRL', $object->getPrice()->getCurrency()->getName());
 }
Esempio n. 30
0
 /**
  * Add an element or fieldset
  *
  * If $elementOrFieldset is an array or Traversable, passes the argument on
  * to the composed factory to create the object before attaching it.
  *
  * $flags could contain metadata such as the alias under which to register
  * the element or fieldset, order in which to prioritize it, etc.
  *
  * @param  array|Traversable|ElementInterface $elementOrFieldset
  * @param  array                              $flags
  * @return \Zend\Form\Fieldset|\Zend\Form\FieldsetInterface|\Zend\Form\FormInterface
  */
 public function add($elementOrFieldset, array $flags = array())
 {
     // TODO: find a better solution than duplicating the factory code, the problem being that if $elementOrFieldset is an array,
     // it is passed by value, and we don't get back the concrete ElementInterface
     if (is_array($elementOrFieldset) || $elementOrFieldset instanceof Traversable && !$elementOrFieldset instanceof ElementInterface) {
         $factory = $this->getFormFactory();
         $elementOrFieldset = $factory->create($elementOrFieldset);
     }
     parent::add($elementOrFieldset, $flags);
     if ($elementOrFieldset instanceof Fieldset && $elementOrFieldset->useAsBaseFieldset()) {
         $this->baseFieldset = $elementOrFieldset;
     }
     return $this;
 }