当前位置: 首页>>代码示例>>PHP>>正文


PHP Form::setAttributes方法代码示例

本文整理汇总了PHP中Zend\Form\Form::setAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::setAttributes方法的具体用法?PHP Form::setAttributes怎么用?PHP Form::setAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Form\Form的用法示例。


在下文中一共展示了Form::setAttributes方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getForm

 public function getForm(array $staff)
 {
     if (!$this->form) {
         $attendanceId = new Element\Hidden();
         $attendanceId->setName('attendanceId');
         $staffId = new Element\Select();
         $staffId->setName('staffId')->setLabel('Staff')->setAttribute('class', 'form-control')->setEmptyOption('-- Choose --')->setValueOptions($staff);
         $type = new Element\Select();
         $type->setName('type')->setLabel('Type')->setAttribute('class', 'form-control')->setValueOptions(array('I' => 'In', 'O' => 'Out'));
         $date = new Element\Date();
         $date->setName('attendanceDate')->setLabel('Date')->setAttributes(array('class' => 'form-control', 'allowPastDates' => true, 'momentConfig' => array('format' => 'YYYY-MM-DD')));
         $workingHours = array();
         for ($i = 8; $i < 20; $i++) {
             $workingHours[$i] = sprintf('%02d', $i);
         }
         $hour = new Element\Select();
         $hour->setName('hour')->setAttribute('class', 'form-control')->setValueOptions($workingHours);
         $workingMinutes = array();
         for ($i = 0; $i < 12; $i++) {
             $workingMinutes[$i] = sprintf('%02d', $i * 5);
         }
         $minute = new Element\Select();
         $minute->setName('minute')->setAttribute('class', 'form-control')->setValueOptions($workingMinutes);
         $form = new Form();
         $form->setAttributes(array('role' => 'form', 'class' => 'form-horizontal'));
         $form->add($attendanceId);
         $form->add($staffId);
         $form->add($type);
         $form->add($date);
         $form->add($hour);
         $form->add($minute);
         $this->form = $form;
     }
     return $this->form;
 }
开发者ID:khinmyatkyi,项目名称:Office_Management,代码行数:35,代码来源:AttendanceBoardHelper.php

示例2: getForm

 protected function getForm()
 {
     if (null === $this->form) {
         $this->form = new ZfForm(null, $this->attributes);
         $this->form->setAttributes($this->attributes);
     }
     return $this->form;
 }
开发者ID:astek-go,项目名称:zf2-datagrid,代码行数:8,代码来源:Form.php

示例3: __invoke

 public function __invoke($id)
 {
     $html = "";
     $auth = $this->sm->get('ZfcRbac\\Service\\AuthorizationService');
     $zfcuserauth = $this->sm->get('zfcuser_auth_service');
     $objectmanager = $this->sm->get('Doctrine\\ORM\\EntityManager');
     $type = $objectmanager->getRepository('Application\\Entity\\OpSupType')->find($id);
     if ($zfcuserauth->hasIdentity()) {
         $criteria = array();
         $criteria['organisation'] = $zfcuserauth->getIdentity()->getOrganisation()->getId();
         $criteria['type'] = $id;
         $query = $objectmanager->createQueryBuilder();
         $query->select('o')->from('Application\\Entity\\OperationalSupervisor', 'o')->where('o.type = ?1')->groupBy('o.zone')->setParameter(1, $id);
         if ($zfcuserauth->getIdentity()->getZone()) {
             $query->andWhere($query->expr()->eq('o.zone', '?2'))->setParameter(2, $zfcuserauth->getIdentity()->getZone()->getId());
         }
         $zones = $query->getQuery()->getResult();
         foreach ($zones as $result) {
             $criteria['zone'] = $result->getZone()->getId();
             $zoneid = $result->getZone()->getId();
             $opsups = $objectmanager->getRepository('Application\\Entity\\OperationalSupervisor')->findBy($criteria, array('name' => 'asc'));
             $currentopsup = $objectmanager->getRepository('Application\\Entity\\OperationalSupervisor')->findOneBy(array('organisation' => $zfcuserauth->getIdentity()->getOrganisation()->getId(), 'zone' => $result->getZone()->getId(), 'type' => $id, 'current' => true));
             if ($auth->isGranted('events.mod-opsup')) {
                 $form = new Form();
                 $selectOpSup = new Select('nameopsup');
                 $opsupArray = array();
                 $opsupArray['-1'] = "Choisir Op Sup";
                 foreach ($opsups as $opsup) {
                     $opsupArray[$opsup->getId()] = $opsup->getName();
                 }
                 $selectOpSup->setValueOptions($opsupArray);
                 if ($currentopsup) {
                     $selectOpSup->setAttribute('value', $currentopsup->getId());
                 }
                 $form->add($selectOpSup);
                 $formView = $this->view->form();
                 $form->setAttributes(array('class' => 'navbar-form navbar-left opsup-form type-' . $id . ' zone-' . $zoneid, 'data-typeid' => $id, 'data-zoneid' => $zoneid));
                 $html .= $formView->openTag($form);
                 $html .= '<div class="form-group">';
                 $html .= '<label for="nameopsup">';
                 $html .= ' <span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span> <b>' . $type->getName() . (count($zones) > 1 ? ' (' . $result->getZone()->getShortname() . ')' : '') . ' : </b>';
                 $html .= '<b class="caret"></b></label>';
                 $html .= $this->view->formSelect($form->get('nameopsup')->setAttribute('class', 'form-control'));
                 $html .= '</div>';
                 $html .= $formView->closeTag();
             } else {
                 if ($currentopsup) {
                     $html .= '<p class="navbar-text navbar-left opsup-name type-' . $id . ' zone-' . $zoneid . '" style="margin-left: 0px"' . ' data-typeid="' . $id . '" data-zoneid="' . $zoneid . '">' . '<span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span> <b>' . $type->getName() . (count($zones) > 1 ? ' (' . $result->getZone()->getShortname() . ')' : '') . ' : </b>' . '<span class="opsupname">' . $currentopsup->getName() . '</span><b class="caret"></b></p>';
                 } else {
                     $html .= '<p class="navbar-text navbar-left" style="margin-left: 0px"><em>Aucun Op Sup configuré</em></p>';
                 }
             }
         }
     } else {
         $html .= '<p class="navbar-text navbar-left"><em>Connexion nécessaire</em></p>';
     }
     return $html;
 }
开发者ID:BrunoSpy,项目名称:epeires2,代码行数:58,代码来源:OpSupHelper.php

示例4: testOpenTagUsesNameAsIdIfNoIdAttributePresent

 public function testOpenTagUsesNameAsIdIfNoIdAttributePresent()
 {
     $form = new Form();
     $attributes = array('name' => 'login-form');
     $form->setAttributes($attributes);
     $markup = $this->helper->openTag($form);
     $this->assertContains('name="login-form"', $markup);
     $this->assertContains('id="login-form"', $markup);
 }
开发者ID:nieldm,项目名称:zf2,代码行数:9,代码来源:FormTest.php

示例5: testRender

 public function testRender()
 {
     $form = new Form();
     $attributes = array('name' => 'login-form');
     $form->setAttributes($attributes);
     $form->add(new CityFieldset());
     $form->add(new Submit('send'));
     $markup = $this->helper->__invoke($form);
     $this->assertContains('<form', $markup);
     $this->assertContains('id="login-form"', $markup);
     $this->assertContains('<label><span>Name of the city</span>', $markup);
     $this->assertContains('<fieldset><legend>Country</legend>', $markup);
     $this->assertContains('<input type="submit" name="send"', $markup);
     $this->assertContains('</form>', $markup);
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:15,代码来源:FormTest.php

示例6: __invoke

 public function __invoke()
 {
     $html = "";
     $auth = $this->sm->get('ZfcRbac\\Service\\AuthorizationService');
     $zfcuserauth = $this->sm->get('zfcuser_auth_service');
     $objectmanager = $this->sm->get('Doctrine\\ORM\\EntityManager');
     if ($zfcuserauth->hasIdentity()) {
         $criteria = array();
         $criteria['organisation'] = $zfcuserauth->getIdentity()->getOrganisation()->getId();
         if ($zfcuserauth->getIdentity()->getZone()) {
             $criteria['zone'] = $zfcuserauth->getIdentity()->getZone()->getId();
         }
         $opsups = $objectmanager->getRepository('Application\\Entity\\OperationalSupervisor')->findBy($criteria, array('name' => 'asc'));
         $currentopsup = $objectmanager->getRepository('Application\\Entity\\OperationalSupervisor')->findOneBy(array('organisation' => $zfcuserauth->getIdentity()->getOrganisation()->getId(), 'zone' => $zfcuserauth->getIdentity()->getZone()->getId(), 'current' => true));
         if ($auth->isGranted('events.mod-opsup')) {
             $form = new Form('opsup');
             $selectOpSup = new Select('nameopsup');
             $opsupArray = array();
             $opsupArray['-1'] = "Choisir Op Sup";
             foreach ($opsups as $opsup) {
                 $opsupArray[$opsup->getId()] = $opsup->getName();
             }
             $selectOpSup->setValueOptions($opsupArray);
             if ($currentopsup) {
                 $selectOpSup->setAttribute('value', $currentopsup->getId());
             }
             $form->add($selectOpSup);
             $formView = $this->view->form();
             $form->setAttributes(array('class' => 'navbar-form navbar-left'));
             $html .= $formView->openTag($form);
             $html .= '<div class="form-group">';
             $html .= $this->view->formSelect($form->get('nameopsup')->setAttribute('class', 'form-control'));
             $html .= '</div>';
             $html .= $formView->closeTag();
         } else {
             if ($currentopsup) {
                 $html .= '<p class="navbar-text navbar-left" style="margin-left: 0px">' . $currentopsup->getName() . '</p>';
             } else {
                 $html .= '<p class="navbar-text navbar-left" style="margin-left: 0px"><em>Aucun Op Sup configuré</em></p>';
             }
         }
     } else {
         $html .= '<p class="navbar-text navbar-left"><em>Connexion nécessaire</em></p>';
     }
     return $html;
 }
开发者ID:LeCoyote,项目名称:epeires2,代码行数:46,代码来源:OpSupHelper.php

示例7: getForm

 public function getForm()
 {
     if (!$this->form) {
         $currentPassword = new Element\Password();
         $currentPassword->setName('currentPassword')->setLabel('Old password')->setAttributes(array('class' => 'form-control'));
         $password = new Element\Password();
         $password->setName('password')->setLabel('New password')->setAttributes(array('class' => 'form-control'));
         $retypePassword = new Element\Password();
         $retypePassword->setName('retypePassword')->setLabel('Retype password')->setAttributes(array('class' => 'form-control'));
         $form = new Form();
         $form->setAttributes(array('class' => 'form-horizontal', 'role' => 'form'));
         $form->add($currentPassword);
         $form->add($password);
         $form->add($retypePassword);
         $this->form = $form;
     }
     return $this->form;
 }
开发者ID:khinmyatkyi,项目名称:Office_Management,代码行数:18,代码来源:PasswordHelper.php

示例8: __invoke

 public function __invoke($iponumber = null)
 {
     $html = "";
     $auth = $this->sm->get('ZfcRbac\\Service\\AuthorizationService');
     $zfcuserauth = $this->sm->get('zfcuser_auth_service');
     $objectmanager = $this->sm->get('Doctrine\\ORM\\EntityManager');
     if ($zfcuserauth->hasIdentity()) {
         $ipos = $objectmanager->getRepository('Application\\Entity\\IPO')->findBy(array('organisation' => $zfcuserauth->getIdentity()->getOrganisation()->getId()), array('name' => 'asc'));
         $currentipo = $objectmanager->getRepository('Application\\Entity\\IPO')->findOneBy(array('organisation' => $zfcuserauth->getIdentity()->getOrganisation()->getId(), 'current' => true));
         if ($auth->isGranted('events.mod-ipo')) {
             $form = new Form('ipo');
             $selectIPO = new Select('nameipo');
             $ipoArray = array();
             $ipoArray['-1'] = "Choisir IPO";
             foreach ($ipos as $ipo) {
                 $ipoArray[$ipo->getId()] = $ipo->getName();
             }
             $selectIPO->setValueOptions($ipoArray);
             if ($currentipo) {
                 $selectIPO->setAttribute('value', $currentipo->getId());
             }
             $form->add($selectIPO);
             $formView = $this->view->form();
             $form->setAttributes(array('class' => 'navbar-form navbar-left visible-xs-block visible-md-block visible-lg-block'));
             $html .= $formView->openTag($form);
             $html .= '<div class="form-group visible-xs-block visible-md-block visible-lg-block">';
             $html .= '<label>' . '<span class="glyphicon glyphicon-warning-sign"></span><b> IPO ' . ($iponumber !== null ? $iponumber : '') . ' : </b>';
             $html .= $this->view->formSelect($form->get('nameipo')->setAttribute('class', 'form-control'));
             $html .= '</div>';
             $html .= $formView->closeTag();
         } else {
             if ($currentipo) {
                 $html .= '<p class="navbar-text navbar-left visible-xs-block visible-md-block visible-lg-block"><span class="glyphicon glyphicon-warning-sign"></span><b> IPO ' . ($iponumber !== null ? $iponumber : '') . ' : </b><span id="iponame">' . $currentipo->getName() . '</span></p>';
             } else {
                 $html .= '<p class="navbar-text navbar-left visible-xs-block visible-md-block visible-lg-block"><span class="glyphicon glyphicon-warning-sign"></span><b> IPO ' . ($iponumber !== null ? $iponumber : '') . ' : </b><em>Aucun IPO configuré</em></p>';
             }
         }
     } else {
         $html .= '<p class="navbar-text navbar-left visible-xs-block visible-md-block visible-lg-block"><em>Connexion nécessaire</em></p>';
     }
     return $html;
 }
开发者ID:LeCoyote,项目名称:epeires2,代码行数:42,代码来源:IPOHelper.php

示例9: getForm

 public function getForm(array $formulaList)
 {
     if (!$this->form) {
         $fromDate = new Element\Date('fromDate');
         $fromDate->setAttributes(array('allowPastDates' => true, 'style' => 'width:120px;', 'momentConfig' => array('format' => 'YYYY-MM-DD')));
         $fromDate->setValue(date('Y-m-26', strtotime('-1 month')));
         $toDate = new Element\Date('toDate');
         $toDate->setAttributes(array('allowPastDates' => true, 'style' => 'width:120px;margin-left:5px;', 'momentConfig' => array('format' => 'YYYY-MM-DD')));
         $toDate->setValue(date('Y-m-25', time('')));
         $formula = new Element\Select();
         $formula->setName('formula')->setAttribute('class', 'form-control')->setAttribute('style', 'width:200px')->setValueOptions($formulaList)->setEmptyOption('-- Choose Formula --');
         $form = new Form();
         $form->setAttributes(array('class' => 'form-inline', 'role' => 'form', 'id' => 'process-form'));
         $form->add($fromDate);
         $form->add($toDate);
         $form->add($formula);
         $this->form = $form;
     }
     return $this->form;
 }
开发者ID:khinmyatkyi,项目名称:Office_Management,代码行数:20,代码来源:PayrollHelper.php

示例10: getForm

 public function getForm(array $tableList, array $typeList, array $moduleList)
 {
     if (!$this->form) {
         $cboTable = new Select('tbl_name');
         $cboTable->setAttribute('class', 'form-control')->setValueOptions($tableList)->setEmptyOption("-- Choose Table --");
         $cboGenerate = new Select('type');
         $cboGenerate->setAttribute('class', 'form-control')->setValueOptions($typeList)->setEmptyOption('-- Choose Type --');
         $cboModule = new Select('module');
         $cboModule->setAttribute('class', 'form-control')->setValueOptions($moduleList)->setEmptyOption('-- Choose Module --');
         $txtGenerate = new Textarea('txtGenerate');
         $form = new Form();
         $form->setAttributes(array('role' => 'form', 'id' => 'frmGenerate', 'method' => 'post'));
         $form->add($txtGenerate);
         $form->add($cboTable);
         $form->add($cboGenerate);
         $form->add($cboModule);
         $this->form = $form;
     }
     return $this->form;
 }
开发者ID:khinmyatkyi,项目名称:Office_Management,代码行数:20,代码来源:GenerateHelper.php

示例11: getForm

 public function getForm($managers)
 {
     if (!$this->form) {
         $projectId = new Element\Hidden();
         $projectId->setName('projectId');
         $code = new Element\Text();
         $code->setLabel('Code')->setName('code')->setAttributes(array('class' => 'form-control'), 'placeholder', 'Enter Code');
         $name = new Element\Text();
         $name->setLabel('Name')->setName('name')->setAttributes(array('class' => 'form-control'), 'placeholder', 'Enter Name');
         $description = new Element\Textarea();
         $description->setLabel('Description')->setName('description')->setAttributes(array('class' => 'form-control'), 'placeholder', 'Enter Description');
         $manager = new Element\Select();
         $manager->setLabel('Manager')->setAttribute('class', 'form-control')->setName('managerId')->setEmptyOption('---Choose Manager---')->setValueOptions($managers);
         $startDate = new Element\Date('startDate');
         $startDate->setLabel('Start Date')->setName('startDate')->setAttributes(array('class' => 'form-control', 'allowPastDates' => true, 'momentConfig' => array('format' => 'YYYY-MM-DD')));
         $endDate = new Element\Date('endDate');
         $endDate->setLabel('End Date')->setName('endDate')->setAttributes(array('class' => 'form-control', 'allowPastDates' => true, 'momentConfig' => array('format' => 'YYYY-MM-DD')));
         $group_code = new Element\Text();
         $group_code->setLabel('group_code')->setName('group_code')->setAttributes(array('class' => 'form-control', 'placeholder' => 'Enter Group Code'));
         $status = new Element\Select();
         $status->setLabel('Status')->setName('status')->setAttribute('class', 'form-control')->setValueOptions(array('A' => 'Active', 'D' => 'Inactive'));
         $remark = new Element\Textarea();
         $remark->setLabel('Remark')->setName('remark')->setAttributes(array('class' => 'form-control', 'placeholder' => 'Enter Remark'));
         $form = new Form();
         $form->setAttributes(array('class' => 'form-horizontal', 'enctype' => 'multipart/form-data'));
         $form->add($projectId);
         $form->add($code);
         $form->add($name);
         $form->add($description);
         $form->add($manager);
         $form->add($startDate);
         $form->add($endDate);
         $form->add($group_code);
         $form->add($status);
         $form->add($remark);
         $this->form = $form;
     }
     return $this->form;
 }
开发者ID:khinmyatkyi,项目名称:Office_Management,代码行数:39,代码来源:ProjectHelper.php

示例12: getForm

 public function getForm(array $holidayType)
 {
     if (!$this->form) {
         $hidId = new Hidden();
         $hidId->setName('calendarId');
         $cboType = new Select();
         $cboType->setName('type')->setLabel('Type')->setAttribute('class', 'form-control')->setEmptyOption('-- Choose Types --')->setValueOptions($holidayType);
         $maxYear = date('Y', time()) + 10;
         $datePicker = new DateSelect('date');
         $datePicker->setValue(new \DateTime('now'))->setShouldRenderDelimiters(false)->setMinYear(2011)->setMaxYear($maxYear)->setLabel('Date')->setDayAttributes(array('class' => 'date-control', 'id' => 'dayCombo'))->setMonthAttributes(array('class' => 'date-control', 'id' => 'monthCombo'))->setYearAttributes(array('class' => 'date-control', 'id' => 'yearCombo'));
         $txtTitle = new Text();
         $txtTitle->setName('title')->setLabel('Title')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'Title');
         $form = new Form();
         $form->setAttributes(array('class' => 'form-horizontal', 'role' => 'form'));
         $form->add($hidId);
         $form->add($cboType);
         $form->add($datePicker);
         $form->add($txtTitle);
         $this->form = $form;
     }
     return $this->form;
 }
开发者ID:khinmyatkyi,项目名称:Office_Management,代码行数:22,代码来源:HolidayHelper.php

示例13: Form

            document.getElementById('pg-text-1').innerHTML = 'Upload done';
            document.getElementById('pg-text-2').innerHTML = 'Upload done';
        }
    </script>
</head>
<body>
<?php 
$file = new Element\File('file');
$file->setLabel('File');
$progress_key = new Element\Hidden('progress_key');
$progress_key->setAttribute('id', 'progress_key');
$progress_key->setValue(md5(uniqid(rand())));
$submit = new Element\Submit('submit');
$submit->setValue('Upload!');
$form = new Form("ZendForm");
$form->setAttributes(array('enctype' => 'multipart/form-data', 'action' => 'ZendForm.php', 'target' => 'uploadTarget', 'onsubmit' => 'observeProgress();'));
$form->prepare();
$formhelper = new Helper\Form();
$formfile = new Helper\FormFile();
$formhidden = new Helper\FormHidden();
$formsubmit = new Helper\FormSubmit();
echo $formhelper->openTag($form);
echo $formhidden($progress_key);
echo $formfile($file);
echo $formsubmit($submit);
echo $formhelper->closeTag();
?>
<iframe name="uploadTarget"></iframe>

<div id="progressbar">
    <div class="pg-progressbar">
开发者ID:nieldm,项目名称:zf2,代码行数:31,代码来源:ZendForm.php


注:本文中的Zend\Form\Form::setAttributes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。