php Zend-Form-Fieldset类(方法)实例源码

下面列出了php Zend-Form-Fieldset 类(方法)源码代码实例,从而了解它的用法。

作者:gotcm    项目:gotcm   
/**
  * 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));
 }

作者:netsensi    项目:zf2-foundatio   
/**
  * @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', '/');
 }

作者:hschlet    项目:braintacl   
/** {@inheritdoc} */
 public function renderFieldset(\Zend\View\Renderer\PhpRenderer $view, \Zend\Form\Fieldset $fieldset)
 {
     if ($fieldset->getName()) {
         return parent::renderFieldset($view, $fieldset);
     }
     // Reimplement form renderer to align submit button with elements from Preferences fieldset.
     $output = "<div class='table'>\n";
     foreach ($this->get('Preferences') as $element) {
         if ($element instanceof \Zend\Form\Fieldset) {
             $output .= $view->htmlElement('span', $view->translate($element->getLabel()), array('class' => 'label'), true) . "\n";
             $output .= $view->htmlElement('fieldset', "<legend></legend>\n" . $this->renderFieldset($view, $element));
         } else {
             $output .= $view->formRow($element, 'prepend', false);
             if ($element->getMessages()) {
                 $output .= "\n<div class='row'>\n<span class='cell'></span>\n";
                 $output .= $view->formElementErrors($element, array('class' => 'errors'));
                 $output .= "\n</div>";
             }
         }
         $output .= "\n";
     }
     $output .= "<div class='row'>\n";
     $output .= "<span class='cell'></span>\n";
     $output .= $view->formRow($this->get('Submit'));
     $output .= "\n</div>\n</div>\n";
     return $output;
 }

作者:pnaq5    项目:zf2dem   
public function testCanSetCustomOptionFromConstructor()
 {
     $fieldset = new Fieldset('foo', array('custom' => 'option'));
     $options = $fieldset->getOptions();
     $this->assertArrayHasKey('custom', $options);
     $this->assertEquals('option', $options['custom']);
 }

作者:Ellipizl    项目:dotscm   
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);
 }

作者:debranov    项目:projec   
/**
  * 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);
     }
 }

作者:utrenkne    项目:YAWI   
public function setUp()
 {
     $fs = new Fieldset('test', ['type' => "text"]);
     $fs->setAttribute('class', 'myclass1 myclass2');
     $fs->setName('myField');
     $target = new Form();
     $target->add($fs);
     $this->target = $target;
 }

作者:gotcm    项目:gotcm   
/**
  * 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');
 }

作者:omeka-s-module    项目:Sharin   
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);
 }

作者:iteaoffic    项目:genera   
/**
  * @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')]]);
 }

作者:bitrecruite    项目:CrossApplicantManage   
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'));
 }

作者:phpr    项目:zf-annotated-form   
/**
  * @param Fieldset $fieldset
  */
 protected function handleCollections(Fieldset $fieldset)
 {
     foreach ($fieldset->getFieldsets() as $childFieldset) {
         // Configure collection:
         if ($childFieldset instanceof Collection) {
             $this->configureInputFilter($childFieldset);
         }
         // Search deeper:
         $this->handleCollections($childFieldset);
     }
 }

作者:arstropic    项目:zf2-dashboar   
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;
 }

作者:hschlet    项目:braintacl   
/** {@inheritdoc} */
 public function renderFieldset(\Zend\View\Renderer\PhpRenderer $view, \Zend\Form\Fieldset $fieldset)
 {
     $output = '';
     if ($fieldset->getName() == 'Deploy') {
         foreach ($fieldset as $element) {
             // Default renderer would prepend
             $output .= $view->formRow($element, 'append') . "\n";
         }
     } else {
         $output .= parent::renderFieldset($view, $fieldset);
     }
     return $output;
 }

作者:arstropic    项目:zf-tenstree   
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;
 }

作者:bitrecruite    项目:CrossApplicantManage   
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);
 }

作者:utrenkne    项目:YAWI   
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);
 }

作者:debranov    项目:contac   
/**
  * 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")]]);
 }

作者:debranov    项目:projec   
/**
  * 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")]]);
 }

作者:debranov    项目:projec   
/**
  * 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")]]);
 }


问题


面经


文章

微信
公众号

扫码关注公众号