/** * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); // Add a form field to the existing block configuration form. $form['name'] = array('#type' => 'textfield', '#title' => t('Your Name')); return $form; }
/** * {@inheritdoc} */ public function blockForm($form, &$form_state) { $form = parent::blockForm($form, $form_state); $config = $this->getConfiguration(); $form['demo_block_settings'] = array('#type' => 'textfield', '#title' => $this->t('Who'), '#description' => $this->t('Our custom block'), '#default_value' => isset($config['demo_block_settings']) ? $config['demo_block_settings'] : ''); return $form; }
/** * Overrides \Drupal\Core\Block\BlockBase::blockForm(). */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); // Retrieve existing configuration for this block. $config = $this->getConfiguration(); // Add a form field to the existing block configuration form. $form['flickr_items'] = array('#type' => 'select', '#title' => t('Number of items'), '#options' => array(10 => 10, 12 => 12, 15 => 15, 16 => 16, 18 => 18, 20 => 20), '#description' => t('Number of items that will be shown in the slideshow.'), '#default_value' => isset($config['flickr_items']) ? $config['flickr_items'] : ''); // $config = $this->configuration; // $defaults = $this->defaultConfiguration(); // $form['flickr_items'] = array( // '#type' => 'select', // '#title' => t('Number of items'), // '#options' => array( // 10 => 10, // 12 => 12, // 15 => 15, // 16 => 16, // 18 => 18, // 20 => 20 // ), // '#description' => t('This number of items will be shown in the Flickr block'), // '#default_value' => $config['flickr_items'], // ); // return $form; }
/** * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); $config = $this->getConfiguration(); $form['hello_block_settings'] = array('#type' => 'textfield', '#title' => $this->t('Who'), '#description' => $this->t('Who do you want to say hello to?'), '#default_value' => isset($config['hello_block_settings']) ? $config['hello_block_settings'] : ''); return $form; }
/** * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); $config = $this->getConfiguration(); $form['unibuc_weather_api_key'] = array('#type' => 'textfield', '#title' => $this->t('Api Key'), '#description' => $this->t('Apy Key for openweathermap.org'), '#default_value' => isset($config['unibuc_weather_api_key']) ? $config['unibuc_weather_api_key'] : ''); $form['unibuc_weather_api_display'] = array('#type' => 'select', '#title' => $this->t('Display in'), '#options' => array('c' => 'C', 'f' => 'F'), '#description' => $this->t('How to display the temperature.'), '#default_value' => isset($config['unibuc_weather_api_display']) ? $config['unibuc_weather_api_display'] : ''); return $form; }
/** * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); // Retrieve existing configuration for this block. $config = $this->getConfiguration(); // Add a form field to the existing block configuration form. $form['hello_text'] = array('#type' => 'textfield', '#title' => t('Hello text'), '#default_value' => isset($config['hello_text']) ? $config['hello_text'] : ''); return $form; }
/** * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); // Retrieve existing configuration for this block. $config = $this->getConfiguration(); // Add a form field to the existing block configuration form. $form['slideshow_items'] = array('#type' => 'select', '#title' => t('Number of items'), '#options' => array(3 => 3, 5 => 5, 7 => 7, 9 => 9, 11 => 11, 13 => 13, 15 => 15, 17 => 17), '#description' => t('Number of items that will be shown in the slideshow.'), '#default_value' => isset($config['slideshow_items']) ? $config['slideshow_items'] : ''); $form['slideshow_order'] = array('#type' => 'select', '#title' => t('Order by'), '#options' => array('created ' => t('Creation date'), 'changed' => t('Date of last change')), '#description' => t('By which date the items will be ordered in the slideshow block'), '#default_value' => isset($config['slideshow_order']) ? $config['slideshow_order'] : ''); return $form; }
/** * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); $config = $this->getConfiguration(); $form['fc_applicationCode'] = array('#type' => 'textfield', '#title' => $this->t("Aplication Code"), '#description' => $this->t("Facebook App-id. If you do not know this see module information."), '#default_value' => isset($config['fc_applicationCode']) ? $config['fc_applicationCode'] : "", '#required' => TRUE); $form['fc_numPosts'] = array('#type' => 'textfield', '#title' => $this->t("Number comment display"), '#description' => $this->t("Number of comment display per page"), '#default_value' => isset($config['fc_numPosts']) ? $config['fc_numPosts'] : "10"); $form['fc_width'] = array('#type' => 'textfield', '#title' => $this->t("Width size"), '#description' => $this->t("Maximum size for display on the page, if the size is in percent must include the symbol ( % )."), '#default_value' => isset($config['fc_width']) ? $config['fc_width'] : "100%"); $form['fc_orderBy'] = array('#type' => 'radios', '#title' => $this->t("Order By"), '#options' => ['social' => $this->t('Social'), 'reverse_time' => $this->t('Desc'), 'time' => $this->t('Asc')], '#description' => $this->t("Select an order to display Comments."), '#default_value' => isset($config['fc_orderBy']) ? $config['fc_orderBy'] : "social"); $form['fc_colorScheme'] = array('#type' => 'radios', '#title' => $this->t("Color Schema"), '#options' => ['light' => $this->t('Light'), 'dark' => $this->t('Dark')], '#description' => $this->t("Select a theme for display comment block."), '#default_value' => isset($config['fc_colorScheme']) ? $config['fc_colorScheme'] : "light"); return $form; }
/** * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); // Retrieve existing configuration for this block. $config = $this->getConfiguration(); // Add a form field to the existing block configuration form. $form['org_name'] = array('#type' => 'textfield', '#title' => t('Organization:'), '#default_value' => isset($config['org_name']) ? $config['org_name'] : ''); $form['org_loca'] = array('#type' => 'textfield', '#title' => t('Location:'), '#default_value' => isset($config['org_loca']) ? $config['org_loca'] : ''); $form['org_mail'] = array('#type' => 'email', '#title' => t('Email ID:'), '#default_value' => isset($config['org_mail']) ? $config['org_mail'] : ''); $form['org_phn'] = array('#type' => 'number', '#title' => t('Contact:'), '#default_value' => isset($config['org_phn']) ? $config['org_phn'] : ''); $form['org_add'] = array('#type' => 'textfield', '#title' => t('Address:'), '#default_value' => isset($config['org_add']) ? $config['org_add'] : ''); return $form; }
/** * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); $config = $this->getConfiguration(); $form['flickr_source'] = array('#type' => 'select', '#title' => t('Source pulling images'), '#default_value' => isset($config['flickr_source']) ? $config['flickr_source'] : 'user', '#description' => $this->t('Pulling from a Flickr user or Flickr group or Flickr user set or Tag'), '#options' => array('user' => 'User', 'group' => 'Group', 'user_set' => 'User set', 'all_tag' => 'Tag')); $form['flickr_userId'] = array('#type' => 'textfield', '#title' => $this->t('Flickr User ID:'), '#description' => $this->t('Input your Flickr User ID'), '#default_value' => isset($config['flickr_userId']) ? $config['flickr_userId'] : '', '#states' => array('visible' => array('select[name="settings[flickr_source]"]' => array('value' => t('user'))))); $form['flickr_groupId'] = array('#type' => 'textfield', '#title' => $this->t('Flickr Group ID:'), '#description' => $this->t('Input your Flickr Group ID'), '#default_value' => isset($config['flickr_groupId']) ? $config['flickr_groupId'] : '', '#states' => array('visible' => array('select[name="settings[flickr_source]"]' => array('value' => t('group'))))); $form['flickr_setId'] = array('#type' => 'textfield', '#title' => $this->t('Set ID:'), '#description' => $this->t('Input your Flickr Set ID'), '#default_value' => isset($config['flickr_setId']) ? $config['flickr_setId'] : '', '#states' => array('visible' => array('select[name="settings[flickr_source]"]' => array('value' => t('user_set'))))); $form['flickr_tag'] = array('#type' => 'textfield', '#title' => $this->t('Tags:'), '#description' => $this->t('Each tag needs to be seperated by a comma'), '#default_value' => isset($config['flickr_tag']) ? $config['flickr_tag'] : '', '#states' => array('visible' => array('select[name="settings[flickr_source]"]' => array('value' => t('all_tag'))))); $form['flickr_num_photo'] = array('#type' => 'select', '#title' => t('Number of images being pulled'), '#default_value' => isset($config['flickr_num_photo']) ? $config['flickr_num_photo'] : 4, '#description' => $this->t('How many images to show in Flickr block'), '#options' => array(2 => '2', 3 => '3', 4 => '4', 5 => '5', 6 => '6', 7 => '7', 8 => '8', 9 => '9', 10 => '10')); $form['flickr_display'] = array('#type' => 'select', '#title' => $this->t('Ordering your images'), '#description' => $this->t('You can get random or latest images from Flickr'), '#options' => array('latest' => 'Latest Images', 'random' => 'Random Images'), '#default_value' => isset($config['flickr_display']) ? $config['flickr_display'] : 'latest'); $form['flickr_image_size'] = array('#type' => 'select', '#title' => $this->t('Size of your images'), '#description' => $this->t('Small square box (75 pixels by 75 pixels), Thumbnail size (longest side is 100 pixels), and Medium size(longest side is 240 pixels)'), '#options' => array('t' => 'Thumbnail', 's' => 'Small', 'm' => 'Medium'), '#default_value' => isset($config['flickr_image_size']) ? $config['flickr_image_size'] : 't'); $form['flickr_layout'] = array('#type' => 'select', '#title' => $this->t('Layout display images'), '#description' => $this->t('Layout can be horizontal or default div tag for render HTML output'), '#options' => array('x' => 'Default', 'h' => 'Horizontal'), '#default_value' => isset($config['flickr_layout']) ? $config['flickr_layout'] : 'x'); return $form; }
/** * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); $config = $this->getConfiguration(); $form['settings'] = array('#type' => 'details', '#title' => $this->t('Button settings'), '#open' => TRUE); $form['settings']['block_url'] = array('#type' => 'textfield', '#default_value' => $config['block_url'], '#description' => $this->t('URL of the page to like (could be your homepage or a facebook page e.g.)<br> You can also specify <current> to establish the url for the current viewed page in your site')); $form['appearance'] = array('#type' => 'details', '#title' => $this->t('Button appearance'), '#open' => FALSE); $form['appearance']['layout'] = array('#type' => 'select', '#title' => $this->t('Layout style'), '#options' => array('standard' => $this->t('Standard'), 'box_count' => $this->t('Box Count'), 'button_count' => $this->t('Button Count'), 'button' => $this->t('Button')), '#default_value' => $config['layout'], '#description' => $this->t('Determines the size and amount of social context next to the button')); // The actial values passed in from the options will be converted to a boolean // in the validation function, so it doesn't really matter what we use. $form['appearance']['show_faces'] = array('#type' => 'select', '#title' => $this->t('Display faces in the box'), '#options' => array(TRUE => $this->t('Show faces'), FALSE => $this->t('Do not show faces')), '#default_value' => $config['show_faces'], '#description' => $this->t('Show profile pictures below the button. Only works with Standard layout')); $form['appearance']['action'] = array('#type' => 'select', '#title' => $this->t('Verb to display'), '#options' => array('like' => $this->t('Like'), 'recommend' => $this->t('Recommend')), '#default_value' => $config['action'], '#description' => $this->t('The verb to display in the button.')); $form['appearance']['font'] = array('#type' => 'select', '#title' => $this->t('Font'), '#options' => array('arial' => 'Arial', 'lucida+grande' => 'Lucida Grande', 'segoe+ui' => 'Segoe UI', 'tahoma' => 'Tahoma', 'trebuchet+ms' => 'Trebuchet MS', 'verdana' => 'Verdana'), '#default_value' => $config['font'], '#description' => $this->t('The font to display in the button')); $form['appearance']['color_scheme'] = array('#type' => 'select', '#title' => $this->t('Color scheme'), '#options' => array('light' => $this->t('Light'), 'dark' => $this->t('Dark')), '#default_value' => $config['color_scheme'], '#description' => $this->t('The color scheme of box environtment')); $form['appearance']['language'] = array('#type' => 'textfield', '#title' => $this->t('Language'), '#default_value' => $config['language'], '#description' => $this->t('Specific language to use. Default is English. Examples:<br />French (France): <em>fr_FR</em><br />French (Canada): <em>fr_CA</em><br />More information can be found at http://developers.facebook.com/docs/internationalization/ and a full XML list can be found at http://www.facebook.com/translations/FacebookLocales.xml')); return $form; }
/** * @param array $form * @param \Drupal\Core\Form\FormStateInterface $form_state */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); $config = $this->getConfiguration(); $form['hello_block_name'] = array( '#type' => 'textfield', '#title' => $this->t('Who'), '#default_value' => isset($config['name']) ? $config['name'] : '', ); $form['hello_block_desc'] = array( '#type' => 'textarea', '#title' => $this->t('Desc'), '#default_value' => isset($config['desc']) ? $config['desc'] : '', ); return $form; }
/** * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); // Retrieve existing configuration for this block. $config = $this->getConfiguration(); // Add a form field to the existing block configuration form. $options = array_combine( array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 40), array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 40) ); $form['image_count'] = array( '#type' => 'select', '#title' => t('Number of images to display'), '#options' => $options, '#default_value' => isset($config['image_count']) ? $config['image_count'] : '', ); return $form; }
/** * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); // Retrieve existing configuration for this block. $config = $this->getConfiguration(); // Add a form field to the existing block configuration form. $form['mapbox_id'] = array('#type' => 'textfield', '#title' => t('Mapbox ID'), 'description' => 'ID given to you by mapbox as a user', '#default_value' => isset($config['mapbox_id']) ? $config['mapbox_id'] : ''); $form['mapbox_accesstoken'] = array('#type' => 'textfield', '#title' => t('Access Token'), 'description' => 'The map access token provided by mapbox', '#default_value' => isset($config['mapbox_accesstoken']) ? $config['mapbox_accesstoken'] : ''); $form['zoom_level'] = array('#type' => 'number', '#title' => t('Zoom Level'), 'description' => 'The Level of zoom (the higher the level, the closer)', '#default_value' => isset($config['zoom_level']) ? $config['zoom_level'] : ''); $form['center'] = array('#type' => 'textfield', '#title' => t('Map Center'), 'description' => 'The coordinates, separated by comma, where to center the map.', '#default_value' => isset($config['center']) ? $config['center'] : ''); $form['marker_popup'] = array('#type' => 'checkbox', '#title' => t('Marker Popup'), 'description' => 'Show a popup when clicking the marker.', '#default_value' => isset($config['marker_popup']) ? $config['marker_popup'] : ''); $form['marker_view_mode'] = array('#type' => 'textfield', '#title' => t('Maker View Mode'), 'description' => 'View mode to be used when displaying in the popup.', '#default_value' => isset($config['marker_view_mode']) ? $config['marker_view_mode'] : ''); $form['marker_legend'] = array('#type' => 'checkbox', '#title' => t('Marker Lengend'), 'description' => 'Enable the marker legend below the map.', '#default_value' => isset($config['marker_legend']) ? $config['marker_legend'] : ''); $form['marker_cluster'] = array('#type' => 'checkbox', '#title' => t('Marker Clustering'), 'description' => 'Enabling clustering', '#default_value' => isset($config['marker_cluster']) ? $config['marker_cluster'] : ''); $form['marker_proximity_search'] = array('#type' => 'checkbox', '#title' => t('Maker Proximity search'), 'description' => 'Enable the proximity search feature.', '#default_value' => isset($config['marker_proximity_search']) ? $config['marker_proximity_search'] : ''); $form['marker_anchor'] = array('#type' => 'textfield', '#title' => t('Marker Anchor'), 'description' => 'What is considered to be the "tip" of the marker icon.', '#default_value' => isset($config['marker_anchor']) ? $config['marker_anchor'] : ''); $form['marker_filter'] = array('#type' => 'checkbox', '#title' => t('Marker Filtering'), 'description' => 'Filter markers based on the "filter" attribute within the JSON.', '#default_value' => isset($config['marker_filter']) ? $config['marker_filter'] : ''); $form['marker_filter_fields'] = array('#type' => 'textfield', '#title' => t('Marker Field Filters'), 'description' => 'Name of the field that acts as a fulter from the json. Separate multiple fields by a comma.', '#default_value' => isset($config['marker_filter_fields']) ? $config['marker_filter_fields'] : ''); $form['marker_icon_src'] = array('#type' => 'textfield', '#title' => t('Maker Icon Path'), 'description' => 'Path to an image that will be used as a marker pin.', '#default_value' => isset($config['marker_icon_src']) ? $config['marker_icon_src'] : ''); $form['marker_icon_width'] = array('#type' => 'number', '#title' => t('Marker Icon Width'), 'description' => 'Icon width in pixels.', '#default_value' => isset($config['marker_icon_width']) ? $config['marker_icon_width'] : ''); $form['marker_icon_height'] = array('#type' => 'number', '#title' => t('Marker Icon Height'), 'description' => 'Icon height in pixels.', '#default_value' => isset($config['marker_icon_height']) ? $config['marker_icon_height'] : ''); $form['data_path'] = array('#type' => 'number', '#title' => t('View Rest Path'), 'description' => 'Rest Based url path', '#default_value' => isset($config['data_path']) ? $config['data_path'] : ''); return $form; }
/** * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); // Retrieve existing configuration for this block. // @todo convert variable 'photos_block_num_information_pager' to block config. $config = $this->getConfiguration(); // Add a form field to the existing block configuration form. $form['show_sub_album'] = array( '#type' => 'radios', '#title' => t('Show sub-album info'), '#default_value' => isset($config['show_sub_album']) ? $config['show_sub_album'] : 0, '#options' => array(t('Disabled'), t('Enabled')) ); return $form; }
/** * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); $config = $this->getConfiguration(); // Platforms. $form['platforms'] = array('#type' => 'table', '#header' => array($this->t('Platform'), $this->t('Platform URL'), $this->t('Weight')), '#tabledrag' => array(array('action' => 'order', 'relationship' => 'silbing', 'group' => 'platform-order-weight'))); $i = -11; foreach ($this->platformManager->getPlatforms() as $platform_id => $platform) { $form['platforms'][$platform_id]['#attributes']['class'][] = 'draggable'; $form['platforms'][$platform_id]['#weight'] = isset($config['platforms'][$platform_id]['weight']) ? $config['platforms'][$platform_id]['weight'] : $i + 1; $form['platforms'][$platform_id]['label'] = array('#markup' => '<strong>' . $platform['name']->render() . '</strong>'); $form['platforms'][$platform_id]['value'] = array('#type' => 'textfield', '#title' => $platform['name']->render(), '#title_display' => 'invisible', '#size' => 40, '#default_value' => isset($config['platforms'][$platform_id]['value']) ? $config['platforms'][$platform_id]['value'] : '', '#field_prefix' => $platform['instance']->getUrlPrefix(), '#field_suffix' => $platform['instance']->getUrlSuffix(), '#element_validate' => array(array(get_class($platform['instance']), 'validateValue'))); $form['platforms'][$platform_id]['weight'] = array('#type' => 'weight', '#title' => t('Weight for @title', array('@title' => $platform['name']->render())), '#title_display' => 'invisible', '#default_value' => isset($config['platforms'][$platform_id]['weight']) ? $config['platforms'][$platform_id]['weight'] : $i + 1, '#attributes' => array('class' => array('platform-order-weight'))); $i++; } // Appearance. $form['appearance'] = array('#type' => 'details', '#title' => $this->t('Appearance'), '#tree' => TRUE); $form['appearance']['orientation'] = array('#type' => 'select', '#title' => $this->t('Orientation'), '#options' => array('v' => $this->t('vertical'), 'h' => $this->t('horizontal')), '#default_value' => isset($config['appearance']['orientation']) ? $config['appearance']['orientation'] : 'h'); $form['appearance']['show_name'] = array('#type' => 'checkbox', '#title' => $this->t('Show name'), '#description' => $this->t('Show the platform name next to the icon.'), '#default_value' => isset($config['appearance']['show_name']) ? $config['appearance']['show_name'] : 0); // Link Attributes. $form['link_attributes'] = array('#type' => 'details', '#title' => $this->t('Link attributes'), '#tree' => TRUE); $form['link_attributes']['target'] = array('#type' => 'select', '#title' => $this->t('Default target'), '#default_value' => isset($config['link_attributes']['target']) ? $config['link_attributes']['target'] : '<none>', '#options' => array('<none>' => $this->t('Remove target attribute'), '_blank' => $this->t('Open in a new browser window or tab (_blank)'), '_self' => $this->t('Open in the current window (_self)'), '_parent' => $this->t('Open in the frame that is superior to the frame the link is in (_parent)'), '_top' => $this->t('Cancel all frames and open in full browser window (_top)'))); $form['link_attributes']['rel'] = array('#type' => 'select', '#title' => $this->t('Default rel'), '#default_value' => isset($config['link_attributes']['rel']) ? $config['link_attributes']['rel'] : '<none>', '#options' => array('<none>' => $this->t('Remove rel attribute'), 'nofollow' => $this->t('Set nofollow'))); // Icon Sets. $iconsetStyles = $this->iconsetManager->getStyles(); $form['iconset'] = array('#type' => 'details', '#title' => $this->t('Icon Sets'), '#open' => TRUE); $form['iconset']['style'] = array('#type' => 'select', '#title' => $this->t('Icon Style'), '#default_value' => isset($config['iconset']['style']) ? $config['iconset']['style'] : '', '#options' => $iconsetStyles); // Get the possible libarary install locations. // We use it maybe later in the form process, if a iconset is not installed. $installDirs = $this->iconsetFinderService->getInstallDirs(); $installedIconsets = array(); foreach ($this->iconsetManager->getIconsets() as $iconset_id => $iconset) { if (isset($iconset['downloadUrl'])) { $name = \Drupal::l($iconset['name'], Url::fromUri($iconset['downloadUrl'])); } else { $name = $iconset['name']; } $publisher = ''; if (isset($iconset['publisher'])) { $publisher = $this->t('by') . ' '; if (isset($iconset['publisherUrl'])) { $publisher .= \Drupal::l($iconset['publisher'], Url::fromUri($iconset['publisherUrl'])); } else { $publisher .= $iconset['publisher']; } } $installedIconsets[$iconset_id]['name'] = array('#markup' => '<strong>' . $name . '</strong><br />' . $publisher); $installedIconsets[$iconset_id]['styles'] = array('#markup' => implode('<br />', $iconsetStyles[$iconset_id])); if ($iconset['instance']->getPath()) { $installedIconsets[$iconset_id]['examples'] = array('#type' => 'table'); // Use the first iconset style for the sample table. $style = key($iconsetStyles[$iconset_id]); $style = IconsetBase::explodeStyle($style); $style = $style['style']; if ($iconset['instance']->getPath() === 'library' && ($library = $iconset['instance']->getLibrary())) { $installedIconsets[$iconset_id]['examples']['#attached']['library'] = (array) $library; } foreach ($this->platformManager->getPlatforms() as $platform_id => $platform) { $installedIconsets[$iconset_id]['examples']['#header'][] = $platform['name']->render(); $iconElement = $iconset['instance']->getIconElement($platform['instance'], $style); $installedIconsets[$iconset_id]['examples'][1][$platform_id] = array('#type' => 'markup', '#markup' => \Drupal::service('renderer')->render($iconElement)); } } else { $examples = '<strong>' . t('Not installed.') . '</strong><br />'; $examples .= $this->t('To install: @download and copy it to one of these directories:', array('@download' => \Drupal::l($this->t('Download'), Url::fromUri($iconset['downloadUrl'])))); $installDirsIconset = array(); foreach ($installDirs as $dir) { $installDirsIconset[] = $dir . '/' . $iconset_id; } $examples .= '<br /><code>' . preg_replace('/,([^,]+) ?$/', " " . t('or') . " \$1", implode(',<br />', $installDirsIconset), 1) . '</code>'; $installedIconsets[$iconset_id]['examples'] = array('#markup' => $examples); } // Add a weigth to the iconset for sorting. $installedIconsets[$iconset_id]['#weight'] = $iconset['instance']->getPath() ? 0 : 1; } // Sort the array so that installed iconsets shown first. uasort($installedIconsets, array('Drupal\\Component\\Utility\\SortArray', 'sortByWeightProperty')); $form['iconset']['installed_iconsets'] = array('#type' => 'table', '#header' => array($this->t('Name'), $this->t('Sizes'), $this->t('Icon examples and download instructions'))) + $installedIconsets; return $form; }
/** * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { // Fish the page object from the form args. // Prevent serialization error. $form['admin_label']['#markup'] = (string) $form['admin_label']['#markup']; foreach ($form_state->getBuildInfo()['args'] as $arg) { if ($arg instanceof Page) { $this->page = $arg->getExecutable(); } } $block_plugins = \Drupal::service('plugin.manager.block')->getDefinitionsForContexts($this->getContexts()); $block_options = array(); foreach ($block_plugins as $plugin_id => $block_definition) { $block_options[(string) $block_definition['category']][$plugin_id] = (string) $block_definition['admin_label']; } $widget_blocks = $form_state->hasValue(array('settings', 'blocks')) ? $form_state->getValue(array('settings', 'blocks')) : $this->configuration['blocks']; $layout = $form_state->hasValue(array('settings', 'layout')) ? $form_state->getValue(array('settings', 'layout')) : $this->configuration['layout']; $classes = $form_state->hasValue(array('settings', 'classes')) ? $form_state->getValue(array('settings', 'classes')) : $this->configuration['classes']; $ajax_properties = array('#ajax' => array('callback' => array($this, 'widgetBlockAJAXCallback'), 'wrapper' => 'widget-block-wrapper', 'effect' => 'fade')); $form = parent::blockForm($form, $form_state); $layouts = array(); foreach (Layout::layoutPluginManager()->getDefinitions() as $id => $definition) { if ($definition['type'] == 'partial') { $layouts[$id] = $definition['label']; } } $form['layout'] = array('#type' => 'select', '#required' => TRUE, '#title' => t('Widget layout'), '#options' => $layouts, '#default_value' => $layout) + $ajax_properties; $form['blocks'] = array('#type' => 'container', '#prefix' => '<div id="widget-block-wrapper">', '#suffix' => '</div>'); $form['classes'] = array('#type' => 'textfield', '#title' => t('CSS Classes'), '#default_value' => $classes); if (!$layout) { return $form; } if ($layout != $this->configuration['layout']) { $this->configuration['layout'] = $layout; $this->configuration['regions'] = NULL; $this->layoutRegionBag = NULL; } foreach ($this->getLayoutRegions() as $region_id => $region_definition) { $block_config = isset($widget_blocks[$region_id]) ? $widget_blocks[$region_id] : array(); $form['blocks'][$region_id] = array('#type' => 'details', '#title' => $region_definition->getConfiguration()['label'], '#open' => TRUE); $form['blocks'][$region_id]['id'] = array('#type' => 'select', '#title' => t('Block'), '#options' => $block_options, '#default_value' => isset($block_config['id']) ? $block_config['id'] : NULL, '#empty_option' => t('- None -')) + $ajax_properties; $form['blocks'][$region_id]['region'] = array('#type' => 'value', '#value' => $region_id); if (!empty($block_config['id'])) { $block_plugin = \Drupal::service('plugin.manager.block')->createInstance($block_config['id'], $block_config); $form['blocks'][$region_id] += $block_plugin->buildConfigurationForm(array(), $form_state); if ($block_plugin instanceof ContextAwarePluginInterface) { $form['blocks'][$region_id]['context_mapping'] = $this->addContextAssignmentElement($block_plugin, $this->getContexts()); } // @todo Support per-block caching and visibility. Breaks UI right now. unset($form['blocks'][$region_id]['cache']); unset($form['blocks'][$region_id]['visibility']); unset($form['blocks'][$region_id]['visibility_tabs']); } else { //unset($form['blocks'][$region_id]); } } return $form; }
/** * Returns the configuration form elements specific to this block plugin. * * Blocks that need to add form elements to the normal block configuration * form should implement this method. * * @param array $form * The form definition array for the block configuration form. * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. * * @return array $form * The renderable form array representing the entire configuration form. */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); return $form; }
/** * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); $config = $this->getConfiguration(); return $form; }