本文整理汇总了PHP中Zend\Form\FormInterface::get方法的典型用法代码示例。如果您正苦于以下问题:PHP FormInterface::get方法的具体用法?PHP FormInterface::get怎么用?PHP FormInterface::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\FormInterface
的用法示例。
在下文中一共展示了FormInterface::get方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
public function indexAction()
{
$request = $this->getRequest();
$logContent = '';
// initialize when no submit anymore
$data = [];
$data['logmessage'] = $this->form->get('logmessage')->getValue();
if ($request->isPost()) {
$this->form->setData($request->getPost());
if ($this->form->isValid()) {
$data = $this->form->getData();
$this->loggerPriority = $data['logpriority'];
if ($data['logformat'] !== 'simple') {
$this->loggerConfig['writers'][0]['options']['formatter']['name'] = $data['logformat'];
unset($this->loggerConfig['writers'][0]['options']['formatter']['options']);
}
}
}
$logger = new Logger($this->loggerConfig);
// save log data to buffer and make it variable
ob_start();
$logger->log((int) $this->loggerPriority, $data['logmessage']);
$logContent = ob_get_clean();
return new ViewModel(['form' => $this->form, 'logContent' => $logContent]);
}
示例2: createAction
public function createAction()
{
$this->contactForm->get('avatar')->setValue('building');
if ($this->getRequest()->isPost()) {
$this->contactForm->setData($this->getRequest()->getPost());
if ($this->contactForm->isValid()) {
$person = $this->contactService->createCompany($this->contactForm->getData());
return $this->redirect()->toRoute('contacts/view', ['type' => ContactEntry::TYPE_COMPANY, 'id' => $person->getId()->toString()]);
}
}
return new ViewModel(['contactForm' => $this->contactForm]);
}
示例3: render
/**
* Renders the error messages.
* @param \Zend\Form\FormInterface $oForm
* @return string
*/
public function render(\Zend\Form\FormInterface $oForm, $sMessage, $bDismissable = false)
{
$errorHtml = sprintf($this->messageOpenFormat, $sMessage);
$sMessagesArray = array();
foreach ($oForm->getMessages() as $fieldName => $sMessages) {
foreach ($sMessages as $sMessage) {
if ($oForm->get($fieldName)->getAttribute('id')) {
$sMessagesArray[] = sprintf('<a href="#%s">%s</a>', $oForm->get($fieldName)->getAttribute('id'), $oForm->get($fieldName)->getLabel() . ': ' . $sMessage);
} else {
$sMessagesArray[] = $oForm->get($fieldName)->getLabel() . ': ' . $sMessage;
}
}
}
return $this->dangerAlert($errorHtml . implode($this->messageSeparatorString, $sMessagesArray) . $this->messageCloseString, $bDismissable);
}
示例4: resetPasswordAction
public function resetPasswordAction()
{
$code = $this->params('code');
if ($code) {
$this->resetPasswordForm->get('code')->setValue($code);
}
if ($this->getRequest()->isPost()) {
$this->resetPasswordForm->setData($this->getRequest()->getPost());
if ($this->resetPasswordForm->isValid()) {
$data = $this->resetPasswordForm->getData();
$this->passwordChanger->resetAccountPassword($data['code'], $data['credential']);
return $this->redirect()->toRoute('login');
}
}
return new ViewModel(['resetPasswordForm' => $this->resetPasswordForm, 'code' => $code]);
}
示例5: changesAction
public function changesAction()
{
$siteId = $this->services->getUtilityService()->getSiteId();
$site = $this->services->getSiteService()->find($siteId);
$fromControl = $this->dateIntervalForm->get(DateIntervalForm::FROM_DATE_NAME);
$toControl = $this->dateIntervalForm->get(DateIntervalForm::TO_DATE_NAME);
$lastDate = $site->getLastUpdate();
$lastDate->setTime(23, 59, 59);
$fromControl->setAttribute('max', $lastDate->format('Y-m-d'));
$toControl->setAttribute('max', $lastDate->format('Y-m-d'));
$from = clone $lastDate;
$from->sub(new \DateInterval('P1M'));
$to = $lastDate;
$fromControl->setValue($from->format('Y-m-d'));
$toControl->setValue($to->format('Y-m-d'));
$request = $this->getRequest();
if ($request->isPost()) {
$this->dateIntervalForm->setData($request->getPost());
if ($this->dateIntervalForm->isValid()) {
$from = \DateTime::createFromFormat('Y-m-d', $fromControl->getValue());
$to = \DateTime::createFromFormat('Y-m-d', $toControl->getValue());
}
}
$from->setTime(0, 0, 0);
$to->setTime(23, 59, 59);
$result = array('intervalForm' => $this->dateIntervalForm, 'site' => $site, 'members' => $this->getMembersData($siteId, $from, $to), 'pages' => $this->getPagesData($siteId, $from, $to), 'revisions' => $this->getRevisionsData($siteId, $from, $to), 'votes' => $this->getVotesData($siteId, $from, $to));
return new ViewModel($result);
}
示例6: render
/**
* @param string $content
* @param array $attribs
* @param ElementInterface $element
* @param FormInterface $form
* @return string
*/
public function render($content, array $attribs = [], ElementInterface $element = null, FormInterface $form = null)
{
if ($form && $form->hasAttribute('class')) {
$class = $form->getAttribute('class');
if (strpos($class, 'form-inline') !== false) {
return $content;
}
if (strpos($class, 'form-horizontal') !== false && empty($attribs['class']) && $form->has('submit') && $form->has('reset')) {
if ($form->get('submit') === $element) {
$attribs['class'] = 'col-xs-12 col-sm-8';
} elseif ($form->get('reset') === $element) {
$attribs['class'] = 'col-xs-12 col-sm-4';
}
}
}
return parent::render($content, $attribs);
}
示例7: renderAdditional
public function renderAdditional(FormInterface $form, $type)
{
$result = '';
foreach ($this->contactTypes[$type] as $fieldName => $fieldOptions) {
$result .= $this->renderElement($form->get($fieldName), $fieldOptions, true);
}
return $result;
}
示例8: editAction
public function editAction()
{
$project = $this->projectRepository->find($this->params('projectId'));
if ($project === null) {
$this->getResponse()->setStatusCode(404);
return;
}
$this->projectForm->get('client')->setValue($project->getClient()->getName());
$this->projectForm->bind($project);
if ($this->getRequest()->isPost()) {
$this->projectForm->setData($this->getRequest()->getPost());
if ($this->projectForm->isValid()) {
$this->projectService->persist($this->projectForm->getData());
$this->redirect()->toRoute('clients/show', ['clientId' => $project->getClient()->getId()], ['fragment' => 'project-table']);
}
}
return new ViewModel(['form' => $this->projectForm]);
}
示例9: row
/**
* @param $name
* @return Element
*/
public function row($name)
{
if (isset($this->cache[$name])) {
return $this->cache[$name];
}
$elem = $this->form->get($name);
if ($elem instanceof ZendElement) {
$return = new Element($elem, $this->renderer);
$this->cache[$name] = $return;
return $return;
}
throw new \DomainException('Invalid form element object.');
}