delphi – Erro no Exit de Field com EditMask

Eu tenho um Field cuja propriedade EditMask está preenchida dessa forma !(99)99999-9999;0;_
Resultando assim na máscara (__)_____-____ sem dar aquela mensagem desagradável de Invalid Input Use Escape Key to Exit.

Mas estou com o seguinte problema, se eu preencho (14)_____-____ e tiro o foco do campo ele instantaneamente altera para (__)_____-__14

*A propriedade EditMask está preenchida em um Field do Tipo String de um DataSet.

*O Field está ligado em um DBEdit.

*A Versão do Delphi é 10.3

8 – How can I update an user field via JSON:API?

How do I update user field via JSON API with D8?

EndPoint:https://domainname.com/jsonapi/user/user/

Method:PATCH

Request Header;

Accept:application/vnd.api+json
Content-Type:application/vnd.api+json
X-CSRF-Token:xxxxxxxxxx

Body:

"data": {
        "type": "user--user",
        "id": "xxxxxx-7798-45e5-a16c-xxxxxxxxxxxx",
        "attributes": {
            "field_test1": (
                "data1",
                "dara2"
            )
        }
    }

But below error

        "title": "Method Not Allowed",
        "status": "405",
        "detail": "No route found for "PATCH /jsonapi/user/user/": Method 
        Not Allowed (Allow: POST, GET, HEAD)",

ux field – Exceptions to Enter event in forms

I notice that a lot of modern UI components, specifically chip input fields allow a user to hit enter which adds a new chip. Google’s material framework also has an enter event for adding new chips. https://material.angular.io/components/chips/overview

The question is, is this bad UX? Typically the enter button is used to submit a form, provided the other fields are filled in that is. If this is an exception to the rule, what rules does it raise an exception to?

functions – Issue using ACF Flexible Content Sub Field for Excerpt

I’m developing a site where the blog entries will be made using ACF Pro / Flexible Content Fields. Because the post entry content will no longer be entered into the default content editor, WP is unable to pull an excerpt. I patched together some code from searches earlier today and was able to finally get an excerpt working but it’s now only pulling from the last blog_post_text sub field instead of the first if more than one is entered. In each post, the user can add several instances of each sub-field based on how many text or image blocks the post needs. I’d like to pull the excerpt from the first blog_post_text sub field used (which is usually the intro paragraph to the post).

I’m sure there are better ways to write this but I’ve tried many and this is the one that worked. Any help or guidance would be incredibly appreciated. Just started using ACF recently.

add_filter('the_excerpt', 'your_function_name');

function your_function_name($excerpt) {
  if( have_rows('blog_post_content') ):
  
    while ( have_rows('blog_post_content') ) : the_row(); 
        if( get_row_layout() == 'blog_post_text_content' ): 
      
         $my_acf_field = wp_trim_words(get_sub_field('blog_post_text'), 100);

        endif;
    endwhile;
    else:
    endif;
    return $my_acf_field;
}

enter image description here

navigation – Token support on the menu link field

Is there is any alternative way to make token to work in the Drupal 8 menu link field other than Menu Token module. I want to use token to set as a default value when I am creating new menu, but if I am using Menu Token module, first, I don’t see any option in the node form to enable the token menu. Secondly, I have to manually enable the token option for each menu item under Admin-> Menu after creating a node which I don’t want to do.

I am trying this in Drupal 8, any suggestion would be helpful

8 – How do I unset a field in a node with the help of hook_node_view?

It’s hard to tell exactly what you’re going for, but to elaborate on @kiamlaluno’s comment, you’d want to do something like the following.

First, update your updateDisplay() function to accept your $node’s $build array as a parameter passed by reference. This allows you to make alterations to the variable inside your function that will be preserved outside your function.

// Note the ampersand prepended to the variable's name.
function updateDisplay(&$node_build) {
  // ... code ...
}

Second, it’s preferable to remove access to the field rather than unset it from the array. This will prevent it from being rendered. You can do this by setting the field’s #access value to false. Your updated code might look like:

function updateDisplay(&$node_build) {
  // Remove access to field_test
  $node_build('field_test')('#access') = FALSE;
}

Lastly, you’ll have to update your hook_node_view() implementation to pass the build array to your updateDisplay() function.

function test_node_view(array &$build, DrupalCoreEntityEntityInterface $entity, DrupalCoreEntityDisplayEntityViewDisplayInterface $display, $view_mode) {
  updateDisplay($build);
}

flags – Print user field on a user profile?

I am using:

  • Drupal 8.8.8
  • Open Social 8.4
  • Profile 1.1
  • Flag 4.0-alpha3

I am using the Open Social module which uses profiles and have added a flag to users called “Follow User” (Machine name: follow_user).

I want to show this field on users profiles, so other users can follow users.

How can I display a user field on a profile?

8 – How to use parent paragraph or field name in template_preprocess_file_link function?

We created custom theme suggestion for fields links using this code

function THEME_theme_suggestions_file_link_alter(array &$suggestions, array $variables) {
  $route = Drupal::request()->attributes->get('_route');
  // Adds a template suggestion for all files displayed as links, except in node/add and edit forms
  if ( strpos($route, 'add') === FALSE && strpos($route, 'form') === FALSE ) {
    $custom_suggestions() = 'file_link__button';
  }
}

This allows us to use template_preprocess_file_link() to add more attributes to the file (MIME, weight, description…) like this :

/**
 * Prepares variables to recreate link in file-link--button.html.twig
 * file name & uri, formatted type (with user friendly names) & weight
 *
 */
function THEME_preprocess_file_link__button(&$variables, $hook) {
  // Define user-friendly MIME types name
  $mimes_types_name = (
    'application/vnd.ms-excel' => 'Excel',
    'application/pdf'          => 'PDF',
    // ...
  );
  $file = $variables('file');
  $file_type = $file->getMimeType();
  $variables('file_type') = $file_type;
  if (isset($mimes_types_name($file_type))) {
    $variables('file_type_formatted') = $mimes_types_name($file_type);
  }
  // ...
}

However in none of those function we can access the field name or better its parent to make a dedicated Twig template depending on paragraph parent or field machine name.
In THEME_theme_suggestions_file_link_alter() we could targetthe node type (using the route) but we’re using paragraphs and we can’t access the parent paragraph.

Any suggestion to make more than one Twig template for template_preprocess_file_link() ?

magento2 – Remove “required field” validation in street[0] input Magento 2.3.5

I need to separate the street field into two inputs (street and number), but send them as the same field to the database.

One solution was to create these inputs, concatenate their value with Javascript and insert it into the input street (0). This works quite well, but at the time of going to the billing section I can’t move forward because it indicates that the field is empty, even when I insert a value with javascript.

how can i disable this validation?

It is not an option to use more street lines. I already use the 4 available

I know this seems strange, but because we migrate from M1 to M2 we need it in that way

forms – How to load custom menu field when editing?

I’m extremely new to Drupal so if my question is badly worded I’m sorry. Inside my menu_ui_override.module I have made a made a new field and added a custom submit handler:

function menu_ui_override_form_menu_edit_form_alter(&$form, DrupalCoreFormFormStateInterface $form_state, $form_id) {
  $form('menu_header') = array(
    '#type' => 'textfield',
    '#title' => t('Menu header'),
    '#weight' => '0',
    '#required' => FALSE,
  );

  $form('actions')('submit')('#submit')() = 'menu_ui_override_accept_menu_header_submit';
}

function menu_ui_override_accept_menu_header_submit(&$form, DrupalCoreFormFormStateInterface $form_state) {
  $values = array(
        'menu_header' => $form_state->getValue('menu_header'),
  );
  
  $connection = Drupal::database();

  $connection->update('menu_tree')
  ->fields(array(
    'menu_header' => $values('menu_header'),
  ))
  ->execute();
    
  drupal_set_message(t('Saved'));
}

This seems to save my new field but now I’m not sure how to load the data entered into that field when I go back to edit the menu after saving it. I’m also not sure where to put the logic for this part. Any help would be greatly appreciated!