本文整理汇总了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));
}
示例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;
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}