keyboard – Reason for difference in behaviour of autcomplete interactions in input fields

There seems to be two different schools of thought when it comes to the autocompletion of input fields and I am wondering if there is a particular reason or rationale for each.

Basically, when the user is completing an input field (usually text based) it is typical for autocomplete functionalities to be implemented when there has been previous inputs provided. The user can then choose to continue completing the input or to use the autocomplete feature by:

  • Pressing the ENTER key
  • Pressing the TAB key

Alternatively they can use the mouse and click on the autocomplete suggestion but it breaks the flow of typing from the keyboard.

Is there any particular reason (both from a technical AND user perspective) why some sites use the ENTER key while others use the TAB key for this? I think it creates a confusion because it is likely for a user to go to websites that implement this feature both ways.

finite fields – Standard conjecture on u-invariants?

This is well beyond my expertise, but I just learned some of the history behind
$u$-invariants of fields $F$,
where ($u(F)+1$)-variable quadratic equations always have a non-trivial solution,
but $u(F)$-variable equations may not.
Here is the Wikipedia explanation.
In particular, although it seemed possible that the $u$-invariant of any field was
a power of $2$, it was shown by Merkurev in 1991 that there is a field
with $u$-invariant of any even number. But the hypothesis that it could never
be an odd number was contradicted by Izhboldin in 2001 who constructed a field with $u$-invariant of $9$.1

Q. My question is: Where does this issue stand now, ~20 years later?
Is there some sense
among experts that there is a field with $u$-invariant for any odd number?
Or is it completely open, with no prevailing hypothesis?


1
“Oleg Izhboldin died tragically … at the age of 37 after submitting this article”
ZBL.

users – How do I access profile fields?

You could examine the Profile Entity class here profile / src / Entity / ProfileInterface.php, showing you a list of public methods including its getter methods, eg.:

$profile->getCreatedTime();

Additionally and similar as with Entities in general, you can also call data via either $entity->get('field_name')->getValue() or $entity->field_name->getValue().

See more on that here: Get information from an entity/ Entity methods

So if you have a Profile Entity with a field machine name address, then you could get its data like:

$profile = DrupalprofileEntityProfile::load(123);
$profile->get('address')->getValue();
$profile->address->getValue();

WooCommerce with ACF: custom fields per product variation

I’m a little stuck here. So I have variable products and I need to show the output of a custom field in a custom tab.

So I created a new field in ACF, called ‘test’. I’ve got this to work for the product itself, but the content does not change when I select another variable.

The code I have to add a ‘Post type’ = ‘Product variable’ in ACF.

add_action( 'woocommerce_product_after_variable_attributes', function( $loop, $variation_data, $variation ) {
    global $abcdefgh_i; // Custom global variable to monitor index
    $abcdefgh_i = $loop;
    // Add filter to update field name
    add_filter( 'acf/prepare_field', 'acf_prepare_field_update_field_name' );
    
    // Loop through all field groups
    $acf_field_groups = acf_get_field_groups();
    foreach( $acf_field_groups as $acf_field_group ) {
        foreach( $acf_field_group('location') as $group_locations ) {
            foreach( $group_locations as $rule ) {
                // See if field Group has at least one post_type = Variations rule - does not validate other rules
                if( $rule('param') == 'post_type' && $rule('operator') == '==' && $rule('value') == 'product_variation' ) {
                    // Render field Group
                    acf_render_fields( $variation->ID, acf_get_fields( $acf_field_group ) );
                    break 2;
                }
            }
        }
    }
    
    // Remove filter
    remove_filter( 'acf/prepare_field', 'acf_prepare_field_update_field_name' );
}, 10, 3 );

// Filter function to update field names
function  acf_prepare_field_update_field_name( $field ) {
    global $abcdefgh_i;
    $field('name') = preg_replace( '/^acf(/', "acf($abcdefgh_i)(", $field('name') );
    return $field;
}
    
// Save variation data
add_action( 'woocommerce_save_product_variation', function( $variation_id, $i = -1 ) {
    // Update all fields for the current variation
    if ( ! empty( $_POST('acf') ) && is_array( $_POST('acf') ) && array_key_exists( $i, $_POST('acf') ) && is_array( ( $fields = $_POST('acf')( $i ) ) ) ) {
        foreach ( $fields as $key => $val ) {
            update_field( $key, $val, $variation_id );
        }
    }
}, 10, 2 );

// Add "Product Variation" location rule values
function my_acf_location_rule_values_post_type($choices){

    $keys = array_keys($choices);
    $index = array_search('product', $keys);

    $position = $index === false ? count($choices) : $index + 1;

    $choices = array_merge(
        array_slice($choices, 0, $position),
        array('product_variation' => __('Product Variation', 'auf')),
        array_slice($choices, $position)
    );

    return $choices;
}

add_filter('acf/location/rule_values/post_type', 'my_acf_location_rule_values_post_type');


// Add "Product Variation" location rule match
function my_acf_location_rule_match_post_type($match, $rule, $options, $field_group){

    if ($rule('value') == 'product_variation') {

        $post_type = $options('post_type');

        if ($rule('operator') == "==")
            $match = $post_type == $rule('value');

        elseif ($rule('operator') == "!=")
            $match = $post_type != $rule('value');
    }

    return $match;
}

add_filter('acf/location/rule_match/post_type', 'my_acf_location_rule_match_post_type', 10, 4);

and the code for the tab is

add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
    
    // Adds the new tab
    
    $tabs('test_tab') = array(
        'title'     => __( 'Shipping', 'woocommerce' ),
        'priority'  => 50,
        'callback'  => 'woo_new_product_tab_content'
    );

    return $tabs;

}
function woo_new_product_tab_content() {

    // The new tab content

    echo 'New Product Tab';
    echo 'Here's your new product tab.';
        echo get_field('test', $post_id);
        print_r($post_id);
    
}

Can someone help me on my way with this? Much appreciated!!

Can I retrieve database table content with ACF plugin/custom fields?

Perhaps a silly question but I would want to retrieve data from some database tables (in WordPress). I’m using a template with WPBakery builder which let me output ‘custom fields’ on posts and pages.

Great for when I add a custom field (with ACF plugin) and I can display this data (if filled in) wherever I want. But is it also possible to get data stored in a database table when there’s not a custom field involved?

So for example, database table ‘livingroom’ has the options ‘length’, ‘width’, ‘height’ and for example the length is stored with to 1.80. Then I want to add this field to a single post.

Is there a way to point ACF in the right direction, by saying get the field ‘livingroom.lenght’ for this post? Or is it simple not possible to output the data this way?

I’ll get it to work with php but just wondering if I can use ACF for this.

Thanks for thinking with me!

entities – Do fields that are not displayed affect rendering performance?

This is a general question about how Drupal renders content. Say I have a content type with 20 fields, including some entity references, text fields, integers, and so on.

When I have a lot of fields on a content type, I know that each field slows down operations like saving the content type because each field has to be processed.

However, what about when Drupal renders the content type to display it? If I hide 19 of the 20 fields on “Manage Display” for the content type, will Drupal avoid processing all those fields and have the same performance as rendering a content type that only has 1 field?

sharepoint online – How to configure all fields in a list to be searchable?

On SharePoint Online, I create a list with multiple fields, including Title and Description. I am quite impressive that the Title become almost immediately searchable thru the search box at the top (screen below). However the description field is not searchable.

I believe I am using a modern view page. If the searchbox is not configurable, could I create a search for this list only (in classic view, all list come with a search box).

enter image description here