javascript – how can i make checkbox to not remove tick on page refresh when checked and have the checkbox update the complete field in my database table

I am creating a todo list app in flask python and mysql as my school assignment. problem is i have a “complete” field on my task form and in my db, when i click the checkbox on the form to check it as complete and refresh my web page it goes back to default unchecked and doesn`t update the db.

here is my checkbox:

<td>
        <div class="checkbox-container">
          <input id="chkDone" name="done" type="checkbox"> Mark as Done <span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
        </div>
      </td>

and here is my inline Js:

<script>
function check() {
  document.getElementById("chkDone").checked = true;
}

function uncheck() {
  document.getElementById("chkDone").checked = false;
}
</script>

nodes – Display taxonomy parent tid of a taxonomy term reference field

On a node template , i am displaying a taxonomy term ( entity ref field ).
That taxonomy term has a parent.
How can have that info on the html generated , for css purposes ?

The field.html.twig display this:

<div class="article__categorie-article">
              <div><a href="http://drupal.stackexchange.com/taxonomy/term/27" hreflang="fr">Utilisation de Drupal</a></div>
              <div><a href="http://drupal.stackexchange.com/taxonomy/term/29" hreflang="fr">Rôle</a></div>
</div>

I would like to have smth like

<div class="article__categorie-article">
              <div><a href="http://drupal.stackexchange.com/taxonomy/term/27" hreflang="fr" data-parent-tid="2">Utilisation de Drupal</a></div>
              <div><a href="http://drupal.stackexchange.com/taxonomy/term/29" hreflang="fr" data-parent-tid="4">Rôle</a></div>
</div>

8 – Create a view for an Entity Reference Field on the User Object

I have custom field (Degrees) on the User object that is a list of a certain content-type that I would like to create a View Block for. Do I complete this by

A) Create a View of content-type Degrees and then filter by the current user’s field? Or
B) Create a View of Users and then filter by the current user and add the entity reference as a relationship of the view to display the degrees?

Option A seems more intuitive, but not sure how to go about it since the list is derived from the user field and not the content type..

magento2.3.4 p2 – Admin error : “The value specified in the URL Key field would generate a URL that already exists.”

I am trying to modify my category structure as part of creating a new shop with Porto and Magento 2.

My products were migrated to m2 from m1 using the Migration Tool.

I have been deleting categories and creating new ones. That has worked fine. However, now I am trying to allocate products to categories I am facing errors that say:

“The value specified in the URL Key field would generate a URL that already exists.”

I have tried various fixes, such as:

  • deleting the Rewrite rule for the referenced error URL
  • updating the URL Key for the referenced error URL
  • changing the URL Key for the category
  • deselecting “Create Permanent Redirect for old URL” and changing URL Key for the category

I have read various issues concerning use of URL Keys and rewrite rules but nobody seems to have a definitive answer. My problem is the same as the one referenced here:

The value specified in the URL Key field would generate a URL that already exists after migration from M1

It would be great if someone had a definitive answer to how to fix this error as my categories will not work unless I can get this fixed.

Help! :-]

magento2.3 – how to make Ui admin form field disable dynamically

I have ui componenet form i want to disable one field dynamically when add only.

 <field formElement="select" name="classification" sortOrder="40">
        <settings>
            <dataType>text</dataType>
            <label translate="true">Classification</label>
            <disabled>true</disabled>
            <dataScope>classification</dataScope>
            <validation>
                <rule name="required-entry" xsi:type="boolean">true</rule>
            </validation>
        </settings>
        <formElements>
            <select>
                <settings>
                    <options class="VendorModuleModelObjectSourceDivisionAgeFrontEndClass"/>
                </settings>
            </select>
        </formElements>
    </field>

<disabled>true</disabled> this line disable for all action.
i have refer this link but not getting idea how to use this

8 – How can I alter a query adding an OR clause for a relational field?

My solution:

  • Add a relationship for content referenced from the entity reference field.
  • Add a contextual filter for the entity reference field, using the content ID from the URL as the value. This includes events that have the location set directly.
  • Add a contextual filter for the entity reference field, using the content ID from the URL as the value, using the relationship. This includes events are related to an event that has the location set.

Unfortunately, the contextual filter WHERE group uses AND by default, so no results are returned, so we have to change the type in the WHERE clause.

use DrupalviewsPluginviewsquerySql;
use DrupalviewsViewExecutable;

/**
 * Implements hook_views_query_alter().
 */
function my_module_views_query_alter(ViewExecutable $view, Sql $query) {
  if ($view->id() === 'events') {
    if ($view->current_display === 'block_2') {
      $query->where(0)('type') = 'OR';
    }
  }
}

If there are more contextual filters, you have to create a new OR where group with the fields, and remove them from group 0.

$group0 = &$query->where(0);

// Create a new OR group.
$group_id = $query->setWhereGroup('OR');

// Copy the conditions to the new where group.
$query->addWhereExpression(
    $group_id,
    $group0('conditions')(1)('field'),
    $group0('conditions')(1)('value')
);
$query->addWhereExpression(
    $group_id,
    $group0('conditions')(2)('field'),
    $group0('conditions')(2)('value')
);

// Remove from group 0
unset($group0('conditions')(1));
unset($group0('conditions')(2)); 

8 – How do I create a select field that looks up values from a database?

As the title says. How would I go about setting up a ‘lookup’ function to essentially allow a user to select values from a select or dropdown field (for example), where these values are stored in a database.

I know my way around the Webform module to a decent level but cannot see any options/settings to set up this kind of functionality, given it is quite a common requirement for forms.

The ‘Add webform options’ isn’t something I can use, as there are numerous values, too many to enter manually.

Any help would be appreciated!

migration – Migrate domain access field

I am currently looking for an example of how to migrate data into an domain access field to select the domain for the page in the Domian settings.

Has someone a hint for me on how to map the fields?

I tried the following:

 field_domain_access:
    plugin: default_value
    default_value_callback: abc //id of the domain record 

field_domain_access: 123 // domain_id of the domain record 

Google Speech recognition doesn’t consistently enter the speech into app text field

I cannot figure out the whole pattern but much of the time these days if I use Google Speech to recognise some text to put into a text field eg Facebook’s or Messenger’s, it successfully recognises the text (it shows me) but then when the popup displaying the text goes away, it leaves the text field unchanged, instead of entering the recognised text. It seems to happen mostly if I do some speech recognition, then edit or move the cursor, then some more speech recognition.

Is there any way to force the recognised text into that field or get it into “paste” so I can paste it in?

(Using a Huawei P20 Pro running Android 10 and Microsoft Swiftkey to “activate” Google Speech).

python – Django model set field default to another field

I’ve spent some time reading through other questions but I feel like my problem is different, so here it is:

class myModel(models.Model):
        foo = models.DecimalField(decimal_places=2)
        bar = models.DecimalField(decimal_places=2, default=foo)

I would like bar to take foo as a default value but I get a

TypeError: conversion from DecimalField to Decimal is not supported

What should I do? Should I use the override function, as suggested in other posts?

Thank you in advance!