Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

New answers tagged

0

I just found this module: https://www.drupal.org/project/field_defaults It seems like it might work. But I'll withhold accepting this as the answer unless there are better ideas out there.


0

You can add an entry to your theme's library /themes/theme_name/theme_name.libraries.yml Add ief-js: version: 1.x js: js/custom.js: {} dependencies: - core/jquery /themes/theme_name/theme_name.theme function theme_name_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { if ($form_id == '...


1

You're looking for the bundle key, which can be obtained from the entity type: $entity_type = 'node'; // Load the entity type definition and get its keys. $keys = \Drupal::entityTypeManager() ->getDefinition($entity_type) ->getKeys(); $query = \Drupal::entityQuery($entity_type); // 'bundle' is optional, if not provided it will be the same as ...


0

If your date field is not a DATETIME but a DATE, use a different format. And a better solution would be to use the Datime object constant to get the format. constant DATETIME_STORAGE_FORMAT :: string(12) "Y-m-d\TH:i:s" constant DATE_STORAGE_FORMAT :: string(5) "Y-m-d" Working example. $dtime = DateTime::createFromFormat("m/d/Y - G:i", $row->Date); // ...


0

I couldn't find an answer to this question for Drupal 8 anywhere. With Drupal 8 the colon is added with a CSS file (field.css) in the Classy core theme if you're using it as your base theme. All you have to do is override it in your own CSS file in your theme. So from the original field.css file: .field--label-inline .field__label::after { content: ...


2

You can get the multiple values input in a table format with the draggable option if you choose Autocomplete widget for that field under Manage form display for that Content type (not the Autocomplete (Tags style)). If your field accepts an unlimited number of values the widget will present as one autocomplete input field with a button to Add another item. ...


0

A little surprised how easy this was to fix; but it seems to be working. Console originally created permissions similar to what @esefwan posted and in MyEntityAccessConrtolHandler.php it created this code: protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { /** @var \Drupal\reserve\Entity\MyEntityInterface ...


0

Search for all the configurations listed using drush config-list Then identify the configuration that you would like to delete. Use the below command to delete the configuration drush config-delete


0

I combined Classy's field.html.twig with Rene's suggestion, in the file field--node--field-tags.html.twig: {% set classes = [ 'field', 'field--name-' ~ field_name|clean_class, 'field--type-' ~ field_type|clean_class, 'field--label-' ~ label_display, ] %} {% set title_classes = [ 'field__label', label_display == '...


0

If you don't use Display suite for the given view mode, you can use https://www.drupal.org/project/entdispfieldui instead. (in combination with a number of other modules) Choose a way to integrate 3rd party composer libraries: Either using composer_manager, or using https://github.com/drupal-composer/drupal-project Download and enable entdispfieldui and ...


0

I did some profiling with a query of 100,000 nodes, fetching the field myfield from all nodes of type mybundle. Good: A dynamic query with addField() $connection = \Drupal::database(); $query = $connection->select('node__field_myfield'); $query->condition('node__field_myfield.bundle', 'mybundle'); $query->addField('node__field_myfield', '...


0

You can clear the static entity cache with EntityStorageBase::resetCache: \Drupal::entityTypeManager()->getStorage('parent_entity')->resetCache([$parentEntity->id()]);


0

It seems Field collection/tabular data solution is what you're after. In Drupal 7 the popular module for that was Field collection. In Drupal 8 Paragraphs seems to be popular, although its description is pointing heavily to the current fad of designing content pages with separate sections, it is still a solution that allows for a more structured group of ...


3

I changed file.settings config entry make_unused_managed_files_temporary to true and it seems to do the job. Just hope there won't be any side effects...


0

Builds a list of entity type labels suitable for a Form API options list \Drupal::entityManager()->getEntityTypeLabels(TRUE); Use in form API $element['target_type'] = [ '#type' => 'select', '#title' => t('Type of item to reference'), '#options' => \Drupal::entityManager()->getEntityTypeLabels(TRUE), '#default_value' => '', '#...


0

Ok, finally I got a workaround. I was focussed on entities and computed field, but it turned out to be a death end. So, I change the approach and found the rules_form module. This modules allows apply a rule in the node form, so I created an integer field called delta in my field_collection_parent and populate it with rules when the form is created. In this ...


0

Up-to-date method for Drupal 8 (for field name "field_myfield"): Backup database Edit structure for table node__field_myfield, set new length for column field_myfield_value. Edit structure for table node_revision__field_myfield, set new length for column field_myfield_value. Use Admin Toolbar Extra Tools module, top menu: go to Development > Config editor ...


-1

I think the answer from @ipwa is close but is not quite there. What you want is an output like this: <img src="/fallback.jpg" srcset="/1x.jpg 1x, /2x.jpg 2x, /3x.jpg 3x" /> Here's what you need to do: Enable both the Breakpoint and Repsonsive Image Style modules. Add an image field for uploading 1 image to a content type. Editors should upload the ...


0

You could use hook_form_alter to accomplish this yourmodule_regform_alter($form, $form_state) { global $user; if($user->uid!=<whatever>) { unset($form['field_attended']; } } If you want to use permissions, you could create your own with hook_permission function administer_attendee_permission() { return array('set attendee ...


0

I had a similar error with another module (address in my case). I could fix it by simply re-install the concerned module with drupal console by the following command: drupal module:install address And back to business :)


0

Would like to add that if you want to get list of baseFieldDefinitions available on your installation run drupal debug:plugin field.field_type


2

Implement hook_field_widget_form_alter() to alter form elements of any content entity form. For example how to add a validate callback when you have third party settings stored in the field configuration: /** * Implements hook_field_widget_form_alter(). */ function mymodule_field_widget_form_alter(&$element, FormStateInterface $form_state, $context) {...


0

Follow the examples set by the scheduler module when it loads, inserts, and builds the form. Add the unpublish_on property to the node object with the value of the UNIX timestamp (of when it will unpublish). When the node is saved, the scheduler module will save the unpublish date. $node = node_load(123); $node->unpublish_on = strtotime("2018-06-25 12:23:...


0

You can also see the structure from config file Filename: field.field.node.article.field_tags.yml


0

Here is an example - /** * Implements hook_form_FORM_ID_alter(). */ function mymod_form_field_storage_config_edit_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { $form['enabled'] = array( '#type' => 'checkbox', '#title' => t('Enable'), '#description' => t('If enabled then this module will ...


1

I dealt with this issue a few months back in the jQuery Colorpicker module. I was converting all fields of one type (jquery_colorpicker), to fields of an entirely different type (colorapi_color). With the update of the module from 8.x-1.x to 8.x-2.x, I intended to remove the the original type/plugin (jquery_colorpicker). Then in the update script I intended ...


Top 50 recent answers are included