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


PHP Field::getLabel方法代码示例

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


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

示例1: resolve

 /**
  * @param Field $field
  *
  * @return array
  */
 public function resolve(Field $field)
 {
     $defaults = ['required' => false, 'label' => $field->getLabel()];
     $definition = $this->registry->findDefinitionFor($field->getDocument());
     $attributes = $definition->getAttributes($field);
     return array_merge($defaults, $this->trim($attributes));
 }
开发者ID:tomaszhanc,项目名称:form-field-bundle,代码行数:12,代码来源:AttributeResolver.php

示例2: renderField

 /**
  * Renders a field.
  *
  * @param Field $field A field.
  *
  * @return string
  */
 protected function renderField(Field $field)
 {
     $name = 'advfrm-' . $field->getName();
     $o = $field->getLabel() . PHP_EOL;
     if (isset($_POST[$name])) {
         if (is_array($_POST[$name])) {
             foreach ($_POST[$name] as $val) {
                 $o .= '  ' . stsl($val) . PHP_EOL;
             }
         } else {
             $o .= '  ' . $this->indent(stsl($_POST[$name])) . PHP_EOL;
         }
     } elseif (isset($_FILES[$name])) {
         $o .= '  ' . stsl($_FILES[$name]['name']) . PHP_EOL;
     }
     return $o;
 }
开发者ID:bbfriend,项目名称:advancedform_xh,代码行数:24,代码来源:PlainTextMailView.php

示例3: renderField

 /**
  * Renders a field.
  *
  * @param Field $field A field.
  *
  * @return string (X)HTML
  */
 protected function renderField(Field $field)
 {
     $name = 'advfrm-' . $field->getName();
     $o = '<tr><td class="label">' . XH_hsc($field->getLabel()) . '</td><td class="field">';
     if (isset($_POST[$name])) {
         if (is_array($_POST[$name])) {
             foreach ($_POST[$name] as $val) {
                 $o .= '<div>' . XH_hsc(stsl($val)) . '</div>';
             }
         } else {
             $o .= $this->nl2br(XH_hsc(stsl($_POST[$name])));
         }
     } elseif (isset($_FILES[$name])) {
         $o .= stsl($_FILES[$name]['name']);
     }
     $o .= '</td></tr>' . PHP_EOL;
     return $o;
 }
开发者ID:bbfriend,项目名称:advancedform_xh,代码行数:25,代码来源:HTMLMailView.php

示例4: renderButtonInput

 protected static function renderButtonInput(Field $field)
 {
     return sprintf('<button type="%s" name="%s" value="%s" %s>%s</button>', $field->getType(), $field->getName(), $field->getValue(), $field->getAttributes(), $field->getLabel());
 }
开发者ID:laasti,项目名称:form,代码行数:4,代码来源:ElementsGenerator.php

示例5: getLabel

 /**
  * Returns the label of a field.
  *
  * @param Field $field A field.
  *
  * @return string
  *
  * @global array The configuration of the plugins.
  */
 protected function getLabel(Field $field)
 {
     global $plugin_cf;
     if ($field->getType() == 'hidden') {
         $label = '';
     } elseif (!$field->isRequired()) {
         $label = $field->getLabel();
     } else {
         $label = sprintf($plugin_cf['advancedform']['required_field_mark'], $field->getLabel());
     }
     if ($this->isLabelled($field)) {
         $label = '<label for="advfrm-' . $this->id . '-' . $field->getName() . '">' . $label . '</label>';
     }
     return $label;
 }
开发者ID:bbfriend,项目名称:advancedform_xh,代码行数:24,代码来源:CreateFormTemplateTransaction.php

示例6: validateFilledInField

 /**
  * Validates a filled in field.
  *
  * @return string (X)HTML.
  */
 protected function validateFilledInField()
 {
     $o = '';
     switch ($this->field->getType()) {
         case 'from':
         case 'mail':
             if (!preg_match($this->config['mail_regexp'], stsl($_POST[$this->name]))) {
                 $o .= '<li>' . sprintf($this->l10n['error_invalid_email'], XH_hsc($this->field->getLabel())) . '</li>' . PHP_EOL;
                 Controller::focusField($this->formId, $this->name);
             }
             break;
         case 'date':
             $pattern = '/^([0-9]+)\\' . $this->l10n['date_delimiter'] . '([0-9]+)\\' . $this->l10n['date_delimiter'] . '([0-9]+)$/';
             $matched = preg_match($pattern, stsl($_POST[$this->name]), $matches);
             if (count($matches) == 4) {
                 $month = $matches[strpos($this->l10n['date_order'], 'm') + 1];
                 $day = $matches[strpos($this->l10n['date_order'], 'd') + 1];
                 $year = $matches[strpos($this->l10n['date_order'], 'y') + 1];
             }
             if (!$matched || !checkdate($month, $day, $year)) {
                 $o .= '<li>' . sprintf($this->l10n['error_invalid_date'], XH_hsc($this->field->getLabel())) . '</li>' . PHP_EOL;
                 Controller::focusField($this->formId, $this->name);
             }
             break;
         case 'number':
             if (!ctype_digit(stsl($_POST[$this->name]))) {
                 $o .= '<li>' . sprintf($this->l10n['error_invalid_number'], XH_hsc($this->field->getLabel())) . '</li>' . PHP_EOL;
                 Controller::focusField($this->formId, $this->name);
             }
             break;
         case 'file':
             switch ($_FILES[$this->name]['error']) {
                 case UPLOAD_ERR_OK:
                     if ($this->field->getMaxLength() && $_FILES[$this->name]['size'] > $this->field->getMaxLength()) {
                         $o .= '<li>' . sprintf($this->l10n['error_upload_too_large'], XH_hsc($this->field->getLabel())) . '</li>' . PHP_EOL;
                         Controller::focusField($this->formId, $this->name);
                     }
                     break;
                 case UPLOAD_ERR_INI_SIZE:
                 case UPLOAD_ERR_FORM_SIZE:
                     $o .= '<li>' . sprintf($this->l10n['error_upload_too_large'], XH_hsc($this->field->getLabel())) . '</li>' . PHP_EOL;
                     Controller::focusField($this->formId, $this->name);
                     break;
                 default:
                     $o .= '<li>' . sprintf($this->l10n['error_upload_general'], XH_hsc($this->field->getLabel())) . '</li>' . PHP_EOL;
                     Controller::focusField($this->formId, $this->name);
             }
             $ext = pathinfo($_FILES[$this->name]['name'], PATHINFO_EXTENSION);
             if ($this->field->getFileTypes() != '' && !in_array($ext, explode(',', $this->field->getFileTypes()))) {
                 $o .= '<li>' . sprintf($this->l10n['error_upload_illegal_ftype'], XH_hsc($this->field->getLabel()), XH_hsc($ext)) . '</li>' . PHP_EOL;
                 Controller::focusField($this->formId, $this->name);
             }
             break;
         case 'custom':
             $pattern = $this->field->getConstraint();
             if (!empty($pattern) && !preg_match($pattern, stsl($_POST[$this->name]))) {
                 $msg = $this->field->getErrorMessage() != '' ? $this->field->getErrorMessage() : $this->l10n['error_invalid_custom'];
                 $o .= '<li>' . sprintf($msg, $this->field->getLabel()) . '</li>' . PHP_EOL;
                 Controller::focusField($this->formId, $this->name);
             }
     }
     return $o;
 }
开发者ID:bbfriend,项目名称:advancedform_xh,代码行数:68,代码来源:FieldValidator.php


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