本文整理汇总了PHP中Drupal\Core\Render\Element类的典型用法代码示例。如果您正苦于以下问题:PHP Element类的具体用法?PHP Element怎么用?PHP Element使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Element类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: preRenderRange
/**
* Prepares a #type 'range' render element for input.html.twig.
*
* @param array $element
* An associative array containing the properties of the element.
* Properties used: #title, #value, #description, #min, #max, #attributes,
* #step.
*
* @return array
* The $element with prepared variables ready for input.html.twig.
*/
public static function preRenderRange($element)
{
$element['#attributes']['type'] = 'range';
Element::setAttributes($element, array('id', 'name', 'value', 'step', 'min', 'max'));
static::setAttributes($element, array('form-range'));
return $element;
}
开发者ID:ravibarnwal,项目名称:laraitassociate.in,代码行数:18,代码来源:Range.php
示例2: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
foreach (Element::children($form_state->getValue('stock')) as $sku) {
$stock = $form_state->getValue(['stock', $sku]);
db_merge('uc_product_stock')->key(array('sku' => $sku))->updateFields(array('active' => $stock['active'], 'stock' => $stock['stock'], 'threshold' => $stock['threshold']))->insertFields(array('sku' => $sku, 'active' => $stock['active'], 'stock' => $stock['stock'], 'threshold' => $stock['threshold'], 'nid' => $form_state->getValue('nid')))->execute();
}
drupal_set_message($this->t('Stock settings saved.'));
}
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:11,代码来源:StockEditForm.php
示例3: checkoutSettingsForm
/**
* {@inheritdoc}
*/
public function checkoutSettingsForm(array $form, FormStateInterface $form_state, JobInterface $job)
{
if (!Element::children($form)) {
$form['#description'] = t("The @translator translator doesn't provide any checkout settings.", array('@translator' => $job->getTranslator()->label()));
}
return $form;
}
开发者ID:andrewl,项目名称:andrewlnet,代码行数:10,代码来源:TranslatorPluginUiBase.php
示例4: preRenderUrl
/**
* Prepares a #type 'url' render element for input.html.twig.
*
* @param array $element
* An associative array containing the properties of the element.
* Properties used: #title, #value, #description, #size, #maxlength,
* #placeholder, #required, #attributes.
*
* @return array
* The $element with prepared variables ready for input.html.twig.
*/
public static function preRenderUrl($element)
{
$element['#attributes']['type'] = 'url';
Element::setAttributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
static::setAttributes($element, array('form-url'));
return $element;
}
开发者ID:nsp15,项目名称:Drupal8,代码行数:18,代码来源:Url.php
示例5: assertFallbackFormatter
protected function assertFallbackFormatter($entity, array $formatters = array(), array $expected_output)
{
$display = array('type' => 'fallback', 'settings' => array('formatters' => $formatters));
$output = $entity->test_text->view($display);
$output = array_intersect_key($output, Element::children($output));
$this->assertEqual($output, $expected_output);
}
开发者ID:DrupalTV,项目名称:DrupalTV,代码行数:7,代码来源:FallbackFormatterTestCase.php
示例6: preRenderNumber
/**
* Prepares a #type 'number' render element for theme_input().
*
* @param array $element
* An associative array containing the properties of the element.
* Properties used: #title, #value, #description, #min, #max, #placeholder,
* #required, #attributes, #step, #size.
*
* @return array
* The $element with prepared variables ready for theme_input().
*/
public static function preRenderNumber($element)
{
$element['#attributes']['type'] = 'number';
Element::setAttributes($element, array('id', 'name', 'value', 'step', 'min', 'max', 'placeholder', 'size'));
static::setAttributes($element, array('form-number'));
return $element;
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:18,代码来源:Number.php
示例7: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$forum_config = $this->config('forum.settings');
$vid = $forum_config->get('vocabulary');
$vocabulary = $this->entityManager->getStorage('taxonomy_vocabulary')->load($vid);
if (!$vocabulary) {
throw new NotFoundHttpException();
}
// Build base taxonomy term overview.
$form = parent::buildForm($form, $form_state, $vocabulary);
foreach (Element::children($form['terms']) as $key) {
if (isset($form['terms'][$key]['#term'])) {
$term = $form['terms'][$key]['#term'];
$form['terms'][$key]['term']['#url'] = Url::fromRoute('forum.page', ['taxonomy_term' => $term->id()]);
unset($form['terms'][$key]['operations']['#links']['delete']);
$route_parameters = $form['terms'][$key]['operations']['#links']['edit']['url']->getRouteParameters();
if (!empty($term->forum_container->value)) {
$form['terms'][$key]['operations']['#links']['edit']['title'] = $this->t('edit container');
$form['terms'][$key]['operations']['#links']['edit']['url'] = Url::fromRoute('entity.taxonomy_term.forum_edit_container_form', $route_parameters);
} else {
$form['terms'][$key]['operations']['#links']['edit']['title'] = $this->t('edit forum');
$form['terms'][$key]['operations']['#links']['edit']['url'] = Url::fromRoute('entity.taxonomy_term.forum_edit_form', $route_parameters);
}
// We don't want the redirect from the link so we can redirect the
// delete action.
unset($form['terms'][$key]['operations']['#links']['edit']['query']['destination']);
}
}
// Remove the alphabetical reset.
unset($form['actions']['reset_alphabetical']);
// Use the existing taxonomy overview submit handler.
$form['terms']['#empty'] = $this->t('No containers or forums available. <a href="@container">Add container</a> or <a href="@forum">Add forum</a>.', array('@container' => $this->url('forum.add_container'), '@forum' => $this->url('forum.add_forum')));
return $form;
}
开发者ID:nsp15,项目名称:Drupal8,代码行数:37,代码来源:Overview.php
示例8: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$filter_values = $this->translateFilterValues();
$langcode = $filter_values['langcode'];
$this->languageManager->reset();
$languages = $this->languageManager->getLanguages();
$langname = isset($langcode) ? $languages[$langcode]->getName() : "- None -";
$form['#attached']['library'][] = 'locale/drupal.locale.admin';
$form['langcode'] = array('#type' => 'value', '#value' => $filter_values['langcode']);
$form['strings'] = array('#type' => 'table', '#tree' => TRUE, '#language' => $langname, '#header' => [$this->t('Source string'), $this->t('Translation for @language', ['@language' => $langname])], '#empty' => $this->t('No strings available.'), '#attributes' => ['class' => ['locale-translate-edit-table']]);
if (isset($langcode)) {
$strings = $this->translateFilterLoadStrings();
$plural_formulas = $this->state->get('locale.translation.plurals') ?: array();
foreach ($strings as $string) {
// Cast into source string, will do for our purposes.
$source = new SourceString($string);
// Split source to work with plural values.
$source_array = $source->getPlurals();
$translation_array = $string->getPlurals();
if (count($source_array) == 1) {
// Add original string value and mark as non-plural.
$plural = FALSE;
$form['strings'][$string->lid]['original'] = array('#type' => 'item', '#title' => $this->t('Source string (@language)', array('@language' => $this->t('Built-in English'))), '#title_display' => 'invisible', '#markup' => '<span lang="en">' . String::checkPlain($source_array[0]) . '</span>');
} else {
// Add original string value and mark as plural.
$plural = TRUE;
$original_singular = ['#type' => 'item', '#title' => $this->t('Singular form'), '#markup' => '<span lang="en">' . String::checkPlain($source_array[0]) . '</span>', '#prefix' => '<span class="visually-hidden">' . $this->t('Source string (@language)', array('@language' => $this->t('Built-in English'))) . '</span>'];
$original_plural = ['#type' => 'item', '#title' => $this->t('Plural form'), '#markup' => '<span lang="en">' . String::checkPlain($source_array[1]) . '</span>'];
$form['strings'][$string->lid]['original'] = [$original_singular, ['#markup' => '<br>'], $original_plural];
}
if (!empty($string->context)) {
$form['strings'][$string->lid]['original'][] = ['#type' => 'inline_template', '#template' => '<br><small>{{ context_title }}: <span lang="en">{{ context }}</span></small>', '#context' => ['context_title' => $this->t('In Context'), 'context' => $string->context]];
}
// Approximate the number of rows to use in the default textarea.
$rows = min(ceil(str_word_count($source_array[0]) / 12), 10);
if (!$plural) {
$form['strings'][$string->lid]['translations'][0] = array('#type' => 'textarea', '#title' => $this->t('Translated string (@language)', array('@language' => $langname)), '#title_display' => 'invisible', '#rows' => $rows, '#default_value' => $translation_array[0], '#attributes' => array('lang' => $langcode));
} else {
// Dealing with plural strings.
if (isset($plural_formulas[$langcode]['plurals']) && $plural_formulas[$langcode]['plurals'] > 2) {
// Add a textarea for each plural variant.
for ($i = 0; $i < $plural_formulas[$langcode]['plurals']; $i++) {
$form['strings'][$string->lid]['translations'][$i] = array('#type' => 'textarea', '#title' => $i == 0 ? $this->t('Singular form') : $this->formatPlural($i, 'First plural form', '@count. plural form'), '#rows' => $rows, '#default_value' => isset($translation_array[$i]) ? $translation_array[$i] : '', '#attributes' => array('lang' => $langcode), '#prefix' => $i == 0 ? '<span class="visually-hidden">' . $this->t('Translated string (@language)', array('@language' => $langname)) . '</span>' : '');
}
} else {
// Fallback for unknown number of plurals.
$form['strings'][$string->lid]['translations'][0] = array('#type' => 'textarea', '#title' => $this->t('Singular form'), '#rows' => $rows, '#default_value' => $translation_array[0], '#attributes' => array('lang' => $langcode), '#prefix' => '<span class="visually-hidden">' . $this->t('Translated string (@language)', array('@language' => $langname)) . '</span>');
$form['strings'][$string->lid]['translations'][1] = array('#type' => 'textarea', '#title' => $this->t('Plural form'), '#rows' => $rows, '#default_value' => isset($translation_array[1]) ? $translation_array[1] : '', '#attributes' => array('lang' => $langcode));
}
}
}
if (count(Element::children($form['strings']))) {
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Save translations'));
}
}
$form['pager']['#type'] = 'pager';
return $form;
}
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:62,代码来源:TranslateEditForm.php
示例9: preRenderRadio
/**
* Prepares a #type 'radio' render element for theme_input().
*
* @param array $element
* An associative array containing the properties of the element.
* Properties used: #required, #return_value, #value, #attributes, #title,
* #description.
*
* Note: The input "name" attribute needs to be sanitized before output, which
* is currently done by initializing Drupal\Core\Template\Attribute with
* all the attributes.
*
* @return array
* The $element with prepared variables ready for theme_input().
*/
public static function preRenderRadio($element)
{
$element['#attributes']['type'] = 'radio';
Element::setAttributes($element, array('id', 'name', '#return_value' => 'value'));
if (isset($element['#return_value']) && $element['#value'] !== FALSE && $element['#value'] == $element['#return_value']) {
$element['#attributes']['checked'] = 'checked';
}
static::setAttributes($element, array('form-radio'));
return $element;
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:25,代码来源:Radio.php
示例10: setElementErrorsFromFormState
/**
* Stores the errors of each element directly on the element.
*
* We must provide a way for non-form functions to check the errors for a
* specific element. The most common usage of this is a #pre_render callback.
*
* @param array $elements
* An associative array containing the structure of a form element.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*/
protected function setElementErrorsFromFormState(array &$elements, FormStateInterface &$form_state)
{
// Recurse through all children.
foreach (Element::children($elements) as $key) {
if (isset($elements[$key]) && $elements[$key]) {
$this->setElementErrorsFromFormState($elements[$key], $form_state);
}
}
// Store the errors for this element on the element directly.
$elements['#errors'] = $form_state->getError($elements);
}
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:22,代码来源:FormErrorHandler.php
示例11: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, CartInterface $cart = NULL)
{
$form['#attached']['library'][] = 'uc_cart/uc_cart.styles';
$cart_config = $this->config('uc_cart.settings');
$form['items'] = array('#type' => 'table', '#tree' => TRUE, '#header' => array('remove' => array('data' => $this->t('Remove'), 'class' => array('remove')), 'image' => array('data' => $this->t('Products'), 'class' => array('image')), 'desc' => array('data' => '', 'class' => array('desc')), 'qty' => array('data' => $this->t('Quantity'), 'class' => array('qty')), 'total' => array('data' => $this->t('Total'), 'class' => array('price'))));
$form['data'] = array('#tree' => TRUE, '#parents' => array('items'));
$i = 0;
$subtotal = 0;
foreach ($cart->getContents() as $cart_item) {
$item = \Drupal::moduleHandler()->invoke($cart_item->data->module, 'uc_cart_display', array($cart_item));
if (Element::children($item)) {
$form['items'][$i]['remove'] = $item['remove'];
$form['items'][$i]['remove']['#name'] = 'remove-' . $i;
$form['items'][$i]['image'] = uc_product_get_picture($item['nid']['#value'], 'uc_cart');
$form['items'][$i]['desc']['title'] = $item['title'];
$form['items'][$i]['desc']['description'] = $item['description'];
$form['items'][$i]['qty'] = $item['qty'];
$form['items'][$i]['total'] = array('#theme' => 'uc_price', '#price' => $item['#total'], '#wrapper_attributes' => array('class' => 'total'));
if (!empty($item['#suffixes'])) {
$form['items'][$i]['total']['#suffixes'] = $item['#suffixes'];
}
$form['data'][$i]['module'] = $item['module'];
$form['data'][$i]['nid'] = $item['nid'];
$form['data'][$i]['data'] = $item['data'];
$form['data'][$i]['title'] = array('#type' => 'value', '#value' => $item['title']['#markup']);
$subtotal += $item['#total'];
}
$i++;
}
$form['items'][]['total'] = array('#theme' => 'uc_price', '#prefix' => '<span id="subtotal-title">' . $this->t('Subtotal') . ':</span> ', '#price' => $subtotal, '#wrapper_attributes' => array('colspan' => 5, 'class' => array('subtotal')));
$form['actions'] = array('#type' => 'actions');
// If the continue shopping element is enabled...
if (($cs_type = $cart_config->get('continue_shopping_type')) !== 'none') {
// Add the element to the form based on the element type.
if ($cart_config->get('continue_shopping_type') == 'link') {
$form['actions']['continue_shopping'] = array('#markup' => $this->l($this->t('Continue shopping'), Url::fromUri('internal:' . $this->continueShoppingUrl())));
} elseif ($cart_config->get('continue_shopping_type') == 'button') {
$form['actions']['continue_shopping'] = array('#type' => 'submit', '#value' => $this->t('Continue shopping'), '#submit' => array(array($this, 'submitForm'), array($this, 'continueShopping')));
}
}
// Add the empty cart button if enabled.
if ($cart_config->get('empty_button')) {
$form['actions']['empty'] = array('#type' => 'submit', '#value' => $this->t('Empty cart'), '#submit' => array(array($this, 'emptyCart')));
}
// Add the control buttons for updating and proceeding to checkout.
$form['actions']['update'] = array('#type' => 'submit', '#name' => 'update-cart', '#value' => $this->t('Update cart'), '#submit' => array(array($this, 'submitForm'), array($this, 'displayUpdateMessage')));
$form['actions']['checkout'] = array('#theme' => 'uc_cart_checkout_buttons');
if ($cart_config->get('checkout_enabled')) {
$form['actions']['checkout']['checkout'] = array('#type' => 'submit', '#value' => $this->t('Checkout'), '#button_type' => 'primary', '#submit' => array(array($this, 'submitForm'), array($this, 'checkout')));
}
$this->renderer->addCacheableDependency($form, $cart);
$this->renderer->addCacheableDependency($form, $cart_config);
return $form;
}
开发者ID:pedrocones,项目名称:hydrotools,代码行数:57,代码来源:CartForm.php
示例12: preRender
/**
* {@inheritdoc}
*/
public function preRender(&$element, $rendering_object)
{
$element += array('#prefix' => '<div class=" ' . implode(' ', $this->getClasses()) . '">', '#suffix' => '</div>', '#tree' => TRUE, '#parents' => array($this->group->group_name), '#default_tab' => '');
if ($this->getSetting('id')) {
$element['#id'] = Html::getId($this->getSetting('id'));
}
// By default tabs don't have titles but you can override it in the theme.
if ($this->getLabel()) {
$element['#title'] = SafeMarkup::checkPlain($this->getLabel());
}
$form_state = new \Drupal\Core\Form\FormState();
if ($this->getSetting('direction') == 'vertical') {
$element += array('#type' => 'vertical_tabs', '#theme_wrappers' => array('vertical_tabs'));
$complete_form = array();
$element = \Drupal\Core\Render\Element\VerticalTabs::processVerticalTabs($element, $form_state, $complete_form);
} else {
$element += array('#type' => 'horizontal_tabs', '#theme_wrappers' => array('horizontal_tabs'));
$on_form = $this->context == 'form';
$element = \Drupal\field_group\Element\HorizontalTabs::processHorizontalTabs($element, $form_state, $on_form);
}
// Make sure the group has 1 child. This is needed to succeed at form_pre_render_vertical_tabs().
// Skipping this would force us to move all child groups to this array, making it an un-nestable.
$element['group']['#groups'][$this->group->group_name] = array(0 => array());
$element['group']['#groups'][$this->group->group_name]['#group_exists'] = TRUE;
// Search for a tab that was marked as open. First one wins.
foreach (\Drupal\Core\Render\Element::children($element) as $tab_name) {
if (!empty($element[$tab_name]['#open'])) {
$element[$this->group->group_name . '__active_tab']['#default_value'] = $tab_name;
break;
}
}
}
开发者ID:penguinclub,项目名称:penguinweb_drupal8,代码行数:35,代码来源:Tabs.php
示例13: preRenderPassword
/**
* Prepares a #type 'password' render element for input.html.twig.
*
* @param array $element
* An associative array containing the properties of the element.
* Properties used: #title, #value, #description, #size, #maxlength,
* #placeholder, #required, #attributes.
*
* @return array
* The $element with prepared variables ready for input.html.twig.
*/
public static function preRenderPassword($element)
{
$element['#attributes']['type'] = 'password';
Element::setAttributes($element, array('id', 'name', 'size', 'maxlength', 'placeholder'));
static::setAttributes($element, array('form-text'));
return $element;
}
开发者ID:ravibarnwal,项目名称:laraitassociate.in,代码行数:18,代码来源:Password.php
示例14: preRenderQuantity
/**
* Prepares a #type 'uc_quantity' render element for theme_input().
*
* @param array $element
* An associative array containing the properties of the element.
* Properties used: #title, #value, #description, #size, #maxlength,
* #placeholder, #min, #max, #step, #required, #attributes.
*
* @return array
* The $element with prepared variables ready for theme_input().
*/
public static function preRenderQuantity($element)
{
$element['#attributes']['type'] = 'number';
$element['#attributes']['min'] = 0;
$element['#attributes']['step'] = 1;
Element::setAttributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder', 'min', 'max', 'step'));
static::setAttributes($element, array('form-uc-quantity'));
return $element;
}
开发者ID:pedrocones,项目名称:hydrotools,代码行数:20,代码来源:UcQuantity.php
示例15: preRenderDate
/**
* Adds form-specific attributes to a 'date' #type element.
*
* Supports HTML5 types of 'date', 'datetime', 'datetime-local', and 'time'.
* Falls back to a plain textfield with JS datepicker support. Used as a
* sub-element by the datetime element type.
*
* @param array $element
* An associative array containing the properties of the element.
* Properties used: #title, #value, #options, #description, #required,
* #attributes, #id, #name, #type, #min, #max, #step, #value, #size. The
* #name property will be sanitized before output. This is currently done by
* initializing Drupal\Core\Template\Attribute with all the attributes.
*
* @return array
* The $element with prepared variables ready for #theme 'input__date'.
*/
public static function preRenderDate($element)
{
if (empty($element['#attributes']['type'])) {
$element['#attributes']['type'] = 'date';
}
Element::setAttributes($element, array('id', 'name', 'type', 'min', 'max', 'step', 'value', 'size'));
static::setAttributes($element, array('form-' . $element['#attributes']['type']));
return $element;
}
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:26,代码来源:Date.php
示例16: replacePlaceholders
/**
* Will replace placeholders in the #text offsets.
*
* @param array $data
* Data structures where to replace placeholders.
* @param $variables
* Key value pairs.
*/
protected function replacePlaceholders(&$data, $variables)
{
foreach (Element::children($data) as $key) {
if (isset($data[$key]['#text'])) {
$data[$key]['#text'] = (string) new FormattableMarkup($data[$key]['#text'], $variables);
} else {
$this->replacePlaceholders($data[$key], $variables);
}
}
}
开发者ID:andrewl,项目名称:andrewlnet,代码行数:18,代码来源:TestSource.php
示例17: preRenderCheckbox
/**
* Prepares a #type 'checkbox' render element for input.html.twig.
*
* @param array $element
* An associative array containing the properties of the element.
* Properties used: #title, #value, #return_value, #description, #required,
* #attributes, #checked.
*
* @return array
* The $element with prepared variables ready for input.html.twig.
*/
public static function preRenderCheckbox($element)
{
$element['#attributes']['type'] = 'checkbox';
Element::setAttributes($element, array('id', 'name', '#return_value' => 'value'));
// Unchecked checkbox has #value of integer 0.
if (!empty($element['#checked'])) {
$element['#attributes']['checked'] = 'checked';
}
static::setAttributes($element, array('form-checkbox'));
return $element;
}
开发者ID:ddrozdik,项目名称:dmaps,代码行数:22,代码来源:Checkbox.php
示例18: build
/**
* {@inheritdoc}
*/
public function build()
{
// Get block
$block = $this->getBlock();
// Apply block config.
$block_config = $this->blockConfig();
$block->setConfiguration($block_config);
// Get render array.
$block_elements = $block->build();
// Return an empty array if there is nothing to render.
return Element::isEmpty($block_elements) ? [] : $block_elements;
}
开发者ID:edwardchan,项目名称:d8-drupalvm,代码行数:15,代码来源:BlockBase.php
示例19: displayErrorMessages
/**
* Loops through and displays all form errors.
*
* @param array $form
* An associative array containing the structure of the form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*/
protected function displayErrorMessages(array $form, FormStateInterface $form_state)
{
$error_links = [];
$errors = $form_state->getErrors();
// Loop through all form errors and check if we need to display a link.
foreach ($errors as $name => $error) {
$form_element = FormElementHelper::getElementByName($name, $form);
$title = FormElementHelper::getElementTitle($form_element);
// Only show links to erroneous elements that are visible.
$is_visible_element = Element::isVisibleElement($form_element);
// Only show links for elements that have a title themselves or have
// children with a title.
$has_title = !empty($title);
// Only show links for elements with an ID.
$has_id = !empty($form_element['#id']);
// Do not show links to elements with suppressed messages. Most often
// their parent element is used for inline errors.
if (!empty($form_element['#error_no_message'])) {
unset($errors[$name]);
} elseif ($is_visible_element && $has_title && $has_id) {
$error_links[] = $this->l($title, Url::fromRoute('<none>', [], ['fragment' => $form_element['#id'], 'external' => TRUE]));
unset($errors[$name]);
}
}
// Set normal error messages for all remaining errors.
foreach ($errors as $error) {
$this->drupalSetMessage($error, 'error');
}
if (!empty($error_links)) {
$render_array = [['#markup' => $this->formatPlural(count($error_links), '1 error has been found: ', '@count errors have been found: ')], ['#theme' => 'item_list', '#items' => $error_links, '#context' => ['list_style' => 'comma-list']]];
$message = $this->renderer->renderPlain($render_array);
$this->drupalSetMessage($message, 'error');
}
}
开发者ID:ddrozdik,项目名称:dmaps,代码行数:42,代码来源:FormErrorHandler.php
示例20: preRenderColor
/**
* Prepares a #type 'color' render element for input.html.twig.
*
* @param array $element
* An associative array containing the properties of the element.
* Properties used: #title, #value, #description, #attributes.
*
* @return array
* The $element with prepared variables ready for input.html.twig.
*/
public static function preRenderColor($element)
{
$element['#attributes']['type'] = 'color';
Element::setAttributes($element, array('id', 'name', 'value'));
static::setAttributes($element, array('form-color'));
return $element;
}
开发者ID:papillon-cendre,项目名称:d8,代码行数:17,代码来源:Color.php
注:本文中的Drupal\Core\Render\Element类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论