8 – $form_state values are empty after ajax $form modification

Im doing a module to generate form validation on field length, first i display a select of availble content types. When the target content type is selected an ajax request display the end of the form with an another select wich contain avaibles fields of the content type selected before. When the form is submited form_state values of the step 2 of the form are empty.
When i display the var_dump in the submitform, only ‘content_type’ has a value.

The code here

class OpenLimitLengthSettingsForm extends ConfigFormBase{

const PLACEHOLDERVALUE = '_none';
const LIMITABLEFIELDTYPES = ('integer', 'string_long', 'string', 'text_with_summary', 'text_long', 'text');
const SKIPPEDFIELDS = ('nid', 'vid');
/**
 * Gets the configuration names that will be editable.
 *
 * @return array
 *   An array of configuration object names that are editable if called in
 *   conjunction with the trait's config() method.
 */
protected function getEditableConfigNames()
{
    return array("open_limit_length.config");
}

/**
 * Returns a unique string identifying the form.
 *
 * The returned ID should be a unique string that can be a valid PHP function
 * name, since it's used in hook implementation names such as
 * hook_form_FORM_ID_alter().
 *
 * @return string
 *   The unique string identifying the form.
 */
public function getFormId()
{
    return "open-sendmail-settings-form";
}

public function buildForm(array $form, FormStateInterface $form_state)
{
  $config = $this->config('open_limit_length.config');

  //Loading content types
  $contentTypes = $this->getAllContentTypes();
  $contentTypeOptions = (self::PLACEHOLDERVALUE => $this->t("-- Choisir un type de contenu --"));
  foreach($contentTypes as $contentType){
    $contentTypeOptions($contentType->get('type')) = $contentType->get('name');
  }

  //Building form's render array
  $form("title") = (
    "#markup" => "<h2>".$this->t("Limitation de taille de champ")."</h2>"
  );


  $form("add_limit") = (
      '#type' => 'fieldset',
      '#title' => $this->t("Ajouter une limitation"),
      '#prefix' => '<div id="open_limit_length_mutistep_form">',
      '#suffix' => '</div>'
    );

  $form("add_limit")('content_type') = (
    '#type' => 'select',
    '#title' => $this->t("Type de contenu"),
    '#options' => $contentTypeOptions,
    '#ajax' => (
      'callback' => '::getFieldsOfContentType',
      'wrapper' => 'open_limit_length_mutistep_form'
    )
  );


  $form('add_limit')('available_fields') = (
    '#type' => 'select',
    '#title' => $this->t("Champ à limiter"),
    '#options' => '',
    '#access' => false
  );

  $form('add_limit')('field_limit') = (
    '#type' => 'textfield',
    '#title' => $this->t('Taille maximum'),
    '#attributes' => (
      ' type' => 'number'
    ),
    '#access' => false
  );
  $form('add_limit')('text_limit') = (
    '#type' => 'textarea',
    '#title' => $this->t("Message d'erreur en cas de dépassement de la limite"),
    '#suffix' => '<div><i>'.$this->t("Exemple : Le champ {{field_name}} est limité à {{nb_max_car}}, taille actuelle {{current_nb_car}}").'</i></div>',
    '#access' => false,
  );

  $form('add_limit')('submit') = (
    '#type' => 'submit',
    '#value' => $this->t("Enregistrer"),
    '#access' => false,
  );

    return parent::buildForm($form, $form_state);
}

public function submitForm(array &$form, FormStateInterface $form_state)
{
    var_dump($form_state->getValues());
    exit();
}

private function getAllContentTypes(){
  $types = Drupal::entityTypeManager()
    ->getStorage('node_type')
    ->loadMultiple();
  return $types;
}



$selectedContentType = $form_state->getValues()('content_type');
$entityManager = Drupal::service('entity_field.manager');
if($selectedContentType != self::PLACEHOLDERVALUE){
  $fields = $entityManager->getFieldDefinitions('node', $selectedContentType);
  $optionsFields = (self::PLACEHOLDERVALUE => '-- Choisir un champ --');
  /** @var DrupalCoreFieldBaseFieldDefinition $field */
  foreach($fields as $field){
    if(in_array($field->getType(), self::LIMITABLEFIELDTYPES) && !in_array($field->getName(), self::SKIPPEDFIELDS)){
      $optionsFields($field->getName()) = $field->getLabel();
    }
  }

  $form('add_limit')('available_fields')('#options') = $optionsFields;
  $form('add_limit')('available_fields')('#access') = true;
  $form('add_limit')('field_limit')('#access') = true;
  $form('add_limit')('text_limit')('#access') = true;
  $form('add_limit')('submit')('#access') = true;

  $form_state->setRebuild();

  $response->addCommand(new ReplaceCommand('#open_limit_length_mutistep_form', $form('add_limit')));
}else{
  $response->addCommand(new AlertCommand("Veuillez selectionner un type de contenu valide"));
}

return $response;}}

I’m searching an issue since this morning but nothing solved my problem.
Thanks for your help

Extract a lookup column with multiple values into another list using SharePoint Designer Workflow

I have a list “A” with many columns. One column is “Departments” that is a lookup column and allow multiple values. After save the item, I want to copy each value of “Departments” to another list “B” with 2 columns ‘BID’ and ‘Dept’. Can I do it in SharePoint Designer Workflow?

Example:

List A:

IDNumber: 2

Departments: Math; Bio; Engineering

List B:

BID: 2

Dept: Math

BID: 2

Dept: Bio

BID: 2

Dept: Engineering

I was thinking to extract ‘Departments’ first, then do a loop to save each one in the list B. I’m not very familiar with SharePoint Designer Workflow. How to extract lookup column? How to do a loop to save the data to list B?
Appreciate for any suggestion!

sharepoint online – Flow: how to get deleted item values?

I need to make some updates to a list based on the data deleted in another list. I tried using ‘When an item is deleted’ trigger but when I try to get the data in the column which was just deleted I can only find the following in dynamic content.

enter image description here

I am guessing flow somehow does not provide this data. But then what use is knowing the deleted time if I can’t do anything based on the data that just got deleted?

Anyone know any workarounds for this?

Why is my gradient descent method doesn’t stop at the appropriate values?

def gd(x_list, y_list):
    m = b = 0
    iterations = 10000
    learning_rate = 0.00001
    n = len(x_list)

    sum_x = sum(x_list)
    sum_y = sum(y_list)
    sum_xy = sum((x * y for x, y in zip(x_list, y_list)))

    for i in range(iterations):
        last_m = m
        m = m - learning_rate * 1/n * (-2 * sum_xy + 2 * m * sum_x + 2 * b * sum_x)
        b = b - learning_rate * 1/n * (-2 * sum_y + 2 * last_m * sum_x + 2 * b * n)
        print(m, b)

gd((1, 2, 3, 4, 5), (5, 7, 9, 11, 13))

I am trying to find a line that fits x = (1, 2, 3, 4, 5) and y = (5, 7, 9, 11, 13).

I calculated partial derivatives for (y1 - (mx1 + b)) ^ 2 ... + (yn - (mxn + b)) ^ 2 and trying it apply here. But the values of m and b are just increasing.

Why do my data and pivot table not coincide with sum values in Excel?

I have collected the following data in Excel:

enter image description here

Based on this data, I’ve made a pivot chart in which I put the variable “Row Labels” in the Rows, and the variable “Sum of AVG” in the Values. Now, the pivot chart looks like this:

enter image description here

As one can see, the values in the second column (“AVG in the first table, “Sum of AVG” in the second table) have changed. I wish the values in the second column of the pivot table to be exactly the same as the values of the first table.

How does one go about doing that, and make a chart depicting the values on the y-axis and years on the x-axis afterwards?

plotting – Overlaying a single color with a colorfunction on a MatrixPlot or ArrayPlot to highlight certain values

I’m still new to plotting in Mathematica and have been trying to figure out how to overlay a single color (white) over a color gradient (in this case rainbow) to highlight a range of values in a plot I generated with a mathematical function. I though this would be relatively straightforward since it appeared similar to several other questions asked here (especially this one: Impose the color for one discrete value above a color predefined gradient), but the methodology that the person presented did not solve my problem. This is the original ArrayPlot with the rainbow gradient

enter image description here

I want to highlight a range (say 2-3) with white and if I apply the method used in the linked post by defining a custom colorfunction like

cf = If((2 <= # <= 3), White, Blend("Rainbow", #)) &;

and then apply it to the same array

ArrayPlot(a, PlotLegends -> Automatic, 
 ClippingStyle -> Automatic, ColorFunction -> cf, AspectRatio -> 2, 
 ColorFunctionScaling -> False)

Then I get the following image

enter image description here

The area I want is highlighted but it doesn’t fit in nicely in the rainbow colorfunction as desired and as it seemed to for the previous question. If I do not use the ColorFunctionScaling->False option I get no change to the plot at all. I will note that I tried the other method in that post as well defining a piecewise function and got similar results. I also tried using ColorRule and it worked okay for one value (say 2=white), but I tried several methods for feeding it a range of values and that yield similar results to the second image.

Any insight would be appreciated

lightroom – How do color values change mathematically as you change temperature and tint?

I was wondering what does color temperature do to your pixel’s RGB/LAB values when you adjust it.

I get that things get more yellow or more blue in the case of temperature, but what equation is Lightroom/Camera RAW using? Is it simply 1-uping the B-channel values for every pixel when you move the temperature up a notch?

My other question is this: I noticed that changing the temperature and tint significantly changed the gray values when I converted my photo to black and white and worked in that space. Other color tools actually add color instead, like color grading, so it’s no longer black and white, it gets a cast, and some don’t work at all, like saturation. So does that mean that the A and B values of LAB influence luminance values in black and white? I’m guessing that yellow would make things brighter? Is Lightroom changing L values or does it preserve them and generate a preview on top where color values influence gray values?

I’m trying to program a photo software and maybe one day a camera app so I’m interested in what is specifically going on.

oracle – Index not used in a remote query when values are supplied from a PL/SQL collection

I have a table with primary key column on a remote database:

create table tab (
  id primary key,
  pad
) nologging as
select level id, lpad('x', 800) pad
from dual
connect by level <= 100000;

If I query a few rows from remote table by id, over db link:

create type id_list is table of number;

declare
    type tab_list is table of u.tab@dblink%rowtype;

    v_result tab_list;
    v_id_list id_list := id_list(10003, 10004, 10005);
begin
    select *
    bulk collect into v_result
    from u.tab@dblink
    where id in (select value(i) from table(v_id_list) i);
end;

This simple query takes around 3 seconds to complete. This time is linearly dependent on the number of values in v_id_list collection. Each additional id increases query time by about ~1s.

Query plan on local database is:

PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------------------------------------------------------
| Id  | Operation                           | Name | Starts | E-Rows | A-Rows |   A-Time   |  OMem |  1Mem | Used-Mem |
-----------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                    |      |      1 |        |      3 |00:00:01.68 |       |       |          |
|   1 |  NESTED LOOPS                       |      |      1 |      1 |      3 |00:00:01.68 |       |       |          |
|   2 |   SORT UNIQUE                       |      |      1 |      3 |      3 |00:00:00.01 |  2048 |  2048 | 2048  (0)|
|   3 |    COLLECTION ITERATOR PICKLER FETCH|      |      1 |      3 |      3 |00:00:00.01 |       |       |          |
|*  4 |   FILTER                            |      |      3 |      1 |      3 |00:00:02.69 |       |       |          |
|   5 |    REMOTE                           | TAB  |      3 |        |    300K|00:00:03.45 |       |       |          |
-----------------------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

"   4 - filter(""ID""=VALUE(KOKBF$))"

The remote query was executed 3 times for a total of 300k rows (3 full table scans). Similarly, querying v$sql on
remote database reveals that the following query was executed 3 times:

SELECT /*+ */ "ID","PAD" FROM "U"."TAB" "TAB"

Why is the index not used in this case?

I verified, that the index is used correctly when values are supplied in pure SQL, even from another table:

create table ids nologging as
select 10003 id from dual union all
select 10004 from dual union all
select 10005 from dual;

select *
from u.tab@dblink
where id in (select id from ids);

I also checked that:

  • statistics were refreshed,
  • driving_site hint does not help.

I managed to get Oracle to use index eventually by extracting collection to subquery and adding materialize hint:

with ids AS (
  select /*+ materialize */ value(i)
  from table(v_id_list) i
)
select *
bulk collect into v_result
from u.tab@dblink
where id in (select i.id from ids i);

Is there a better way to tell optimizer to use index, without using explicit hints?

Tested on Oracle 12.1.0.2

Random Number for Transaction Signatures In R Values , how It is created?

I wonder about the random Number used in signatures that result in R values ?
xcoridnate R = G(k)
how it is created ? does it have specific chars length ?
Is there a specific Random generator Used ? or restriction Arguments ?
I saw A Python Code online and found It is limited to max number of field points
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
but as it is in hex format i didn’t know what does it mean
so wat is the max number to be used as it will processed as an integer