Skip to main content
Integrate comments from OPer
Source Link
Pierre.Vriens
  • 36k
  • 40
  • 50
  • 182

I have an inherited project to which I need to add small form api changes. The changes are to two form fields shown below:

$form['start'] = [
    '#type' => 'number',
    '#title' => t('Between:'),
    '#required' => TRUE,
    '#default_value' => 1988,
    '#min' => 1900,
    '#max' => date('Y'),
    '#value' => 1988,
];
$form['test'] = [
    '#type' => 'number',
    '#title' => t('TEST:'),
    '#required' => TRUE,
    '#default_value' => 1988,
    '#max' => date('Y'),
    '#min' => 1900,
    '#value' => 1995,
];
$form['end'] = [
    '#type' => 'number',
    '#title' => t('and'),
    '#required' => TRUE,
    '#min' => 1900,
    '#max' => date('Y'),
    '#default_value' => 1999,
    '#value' => 1999,
];

This is a bizarre problem as my attempts to set the #value and #default_value for both the start and end fields are not working.

However, I created the test field and it successfully adds to the form and sets my configured value and default_value.

So, for the start field, I expect to see 1988 as the displayed value but instead that form field displays 1900. The test field I create meanwhile displays and behaves properly ... go figure.

As it is an inherited project, I wonder if there are other means of configuring a form which I am unaware of ?

UPDATE: Thanks to Leymannx for contributing and attempting to help. As per your suggestions, I tried the following but without success:

$form['start'] = [
    '#type' => 'number',
    '#title' => t('Between:'),
    '#required' => TRUE,
    '#min' => 1900,
    '#max' => idate('Y'),
    '#default_value' => 1988,
];

Note: The problem is that both the start and end fields refuse all my efforts to configure the value and default_value. So, for the start field, I expect to see 1988 but instead that form field displays 1900.

I have an inherited project to which I need to add small form api changes. The changes are to two form fields shown below:

$form['start'] = [
    '#type' => 'number',
    '#title' => t('Between:'),
    '#required' => TRUE,
    '#default_value' => 1988,
    '#min' => 1900,
    '#max' => date('Y'),
    '#value' => 1988,
];
$form['test'] = [
    '#type' => 'number',
    '#title' => t('TEST:'),
    '#required' => TRUE,
    '#default_value' => 1988,
    '#max' => date('Y'),
    '#min' => 1900,
    '#value' => 1995,
];
$form['end'] = [
    '#type' => 'number',
    '#title' => t('and'),
    '#required' => TRUE,
    '#min' => 1900,
    '#max' => date('Y'),
    '#default_value' => 1999,
    '#value' => 1999,
];

This is a bizarre problem as my attempts to set the #value and #default_value for both the start and end fields are not working.

However, I created the test field and it successfully adds to the form and sets my configured value and default_value.

So, for the start field, I expect to see 1988 as the displayed value but instead that form field displays 1900. The test field I create meanwhile displays and behaves properly ... go figure.

As it is an inherited project, I wonder if there are other means of configuring a form which I am unaware of ?

UPDATE: Thanks to Leymannx for contributing and attempting to help. As per your suggestions, I tried the following but without success:

$form['start'] = [
    '#type' => 'number',
    '#title' => t('Between:'),
    '#required' => TRUE,
    '#min' => 1900,
    '#max' => idate('Y'),
    '#default_value' => 1988,
];

I have an inherited project to which I need to add small form api changes. The changes are to two form fields shown below:

$form['start'] = [
    '#type' => 'number',
    '#title' => t('Between:'),
    '#required' => TRUE,
    '#default_value' => 1988,
    '#min' => 1900,
    '#max' => date('Y'),
    '#value' => 1988,
];
$form['test'] = [
    '#type' => 'number',
    '#title' => t('TEST:'),
    '#required' => TRUE,
    '#default_value' => 1988,
    '#max' => date('Y'),
    '#min' => 1900,
    '#value' => 1995,
];
$form['end'] = [
    '#type' => 'number',
    '#title' => t('and'),
    '#required' => TRUE,
    '#min' => 1900,
    '#max' => date('Y'),
    '#default_value' => 1999,
    '#value' => 1999,
];

This is a bizarre problem as my attempts to set the #value and #default_value for both the start and end fields are not working.

However, I created the test field and it successfully adds to the form and sets my configured value and default_value.

So, for the start field, I expect to see 1988 as the displayed value but instead that form field displays 1900. The test field I create meanwhile displays and behaves properly ... go figure.

As it is an inherited project, I wonder if there are other means of configuring a form which I am unaware of ?

UPDATE: Thanks to Leymannx for contributing and attempting to help. As per your suggestions, I tried the following but without success:

$form['start'] = [
    '#type' => 'number',
    '#title' => t('Between:'),
    '#required' => TRUE,
    '#min' => 1900,
    '#max' => idate('Y'),
    '#default_value' => 1988,
];

Note: The problem is that both the start and end fields refuse all my efforts to configure the value and default_value. So, for the start field, I expect to see 1988 but instead that form field displays 1900.

added 366 characters in body
Source Link
sisko
  • 1.7k
  • 1
  • 19
  • 46

I have an inherited project to which I need to add small form api changes. The changes are to two form fields shown below:

$form['start'] = [
    '#type' => 'number',
    '#title' => t('Between:'),
    '#required' => TRUE,
    '#default_value' => 1988,
    '#min' => 1900,
    '#max' => date('Y'),
    '#value' => 1988,
];
$form['test'] = [
    '#type' => 'number',
    '#title' => t('TEST:'),
    '#required' => TRUE,
    '#default_value' => 1988,
    '#max' => date('Y'),
    '#min' => 1900,
    '#value' => 1995,
];
$form['end'] = [
    '#type' => 'number',
    '#title' => t('and'),
    '#required' => TRUE,
    '#min' => 1900,
    '#max' => date('Y'),
    '#default_value' => 1999,
    '#value' => 1999,
];

This is a bizarre problem as my attempts to set the #value and #default_value for both the start and end fields are not working.

However, I created the test field and it successfully adds to the form and sets my configured value and default_value.

So, for the start field, I expect to see 1988 as the displayed value but instead that form field displays 1900. The test field I create meanwhile displays and behaves properly ... go figure.

As it is an inherited project, I wonder if there are other means of configuring a form which I am unaware of ?

UPDATE: Thanks to Leymannx for contributing and attempting to help. As per your suggestions, I tried the following but without success:

$form['start'] = [
    '#type' => 'number',
    '#title' => t('Between:'),
    '#required' => TRUE,
    '#min' => 1900,
    '#max' => idate('Y'),
    '#default_value' => 1988,
];

I have an inherited project to which I need to add small form api changes. The changes are to two form fields shown below:

$form['start'] = [
    '#type' => 'number',
    '#title' => t('Between:'),
    '#required' => TRUE,
    '#default_value' => 1988,
    '#min' => 1900,
    '#max' => date('Y'),
    '#value' => 1988,
];
$form['test'] = [
    '#type' => 'number',
    '#title' => t('TEST:'),
    '#required' => TRUE,
    '#default_value' => 1988,
    '#max' => date('Y'),
    '#min' => 1900,
    '#value' => 1995,
];
$form['end'] = [
    '#type' => 'number',
    '#title' => t('and'),
    '#required' => TRUE,
    '#min' => 1900,
    '#max' => date('Y'),
    '#default_value' => 1999,
    '#value' => 1999,
];

This is a bizarre problem as my attempts to set the #value and #default_value for both the start and end fields are not working.

However, I created the test field and it successfully adds to the form and sets my configured value and default_value.

So, for the start field, I expect to see 1988 as the displayed value but instead that form field displays 1900. The test field I create meanwhile displays and behaves properly ... go figure.

As it is an inherited project, I wonder if there are other means of configuring a form which I am unaware of ?

I have an inherited project to which I need to add small form api changes. The changes are to two form fields shown below:

$form['start'] = [
    '#type' => 'number',
    '#title' => t('Between:'),
    '#required' => TRUE,
    '#default_value' => 1988,
    '#min' => 1900,
    '#max' => date('Y'),
    '#value' => 1988,
];
$form['test'] = [
    '#type' => 'number',
    '#title' => t('TEST:'),
    '#required' => TRUE,
    '#default_value' => 1988,
    '#max' => date('Y'),
    '#min' => 1900,
    '#value' => 1995,
];
$form['end'] = [
    '#type' => 'number',
    '#title' => t('and'),
    '#required' => TRUE,
    '#min' => 1900,
    '#max' => date('Y'),
    '#default_value' => 1999,
    '#value' => 1999,
];

This is a bizarre problem as my attempts to set the #value and #default_value for both the start and end fields are not working.

However, I created the test field and it successfully adds to the form and sets my configured value and default_value.

So, for the start field, I expect to see 1988 as the displayed value but instead that form field displays 1900. The test field I create meanwhile displays and behaves properly ... go figure.

As it is an inherited project, I wonder if there are other means of configuring a form which I am unaware of ?

UPDATE: Thanks to Leymannx for contributing and attempting to help. As per your suggestions, I tried the following but without success:

$form['start'] = [
    '#type' => 'number',
    '#title' => t('Between:'),
    '#required' => TRUE,
    '#min' => 1900,
    '#max' => idate('Y'),
    '#default_value' => 1988,
];
added more clarity
Source Link
sisko
  • 1.7k
  • 1
  • 19
  • 46

I have an inherited project to which I need to add small form api changes. The changes are to two form fields shown below:

$form['start'] = [
    '#type' => 'number',
    '#title' => t('Between:'),
    '#required' => TRUE,
    '#default_value' => 1988,
    '#min' => 1900,
    '#max' => date('Y'),
    '#value' => 1988,
];
$form['test'] = [
    '#type' => 'number',
    '#title' => t('TEST:'),
    '#required' => TRUE,
    '#default_value' => 1988,
    '#max' => date('Y'),
    '#min' => 1900,
    '#value' => 1995,
];
$form['end'] = [
    '#type' => 'number',
    '#title' => t('and'),
    '#required' => TRUE,
    '#min' => 1900,
    '#max' => date('Y'),
    '#default_value' => 1999,
    '#value' => 1999,
];

This is a bizarre problem as my attempts to set the #value and #default_value for both the start and end fields are not working.

However, I created the test field and it successfully adds to the form and sets my configured value and default_value.

So, for the start field, I expect to see 1988 as the displayed value but instead that form field displays 1900. The test field I create meanwhile displays and behaves properly ... go figure.

As it is an inherited project, I wonder if there are other means of configuring a form which I am unaware of ?

I have an inherited project to which I need to add small form api changes. The changes are to two form fields shown below:

$form['start'] = [
    '#type' => 'number',
    '#title' => t('Between:'),
    '#required' => TRUE,
    '#default_value' => 1988,
    '#min' => 1900,
    '#max' => date('Y'),
    '#value' => 1988,
];
$form['test'] = [
    '#type' => 'number',
    '#title' => t('TEST:'),
    '#required' => TRUE,
    '#default_value' => 1988,
    '#max' => date('Y'),
    '#min' => 1900,
    '#value' => 1995,
];
$form['end'] = [
    '#type' => 'number',
    '#title' => t('and'),
    '#required' => TRUE,
    '#min' => 1900,
    '#max' => date('Y'),
    '#default_value' => 1999,
    '#value' => 1999,
];

This is a bizarre problem as my attempts to set the #value and #default_value for both the start and end fields are not working.

However, I created the test field and it successfully adds to the form and sets my configured value and default_value.

As it is an inherited project, I wonder if there are other means of configuring a form which I am unaware of ?

I have an inherited project to which I need to add small form api changes. The changes are to two form fields shown below:

$form['start'] = [
    '#type' => 'number',
    '#title' => t('Between:'),
    '#required' => TRUE,
    '#default_value' => 1988,
    '#min' => 1900,
    '#max' => date('Y'),
    '#value' => 1988,
];
$form['test'] = [
    '#type' => 'number',
    '#title' => t('TEST:'),
    '#required' => TRUE,
    '#default_value' => 1988,
    '#max' => date('Y'),
    '#min' => 1900,
    '#value' => 1995,
];
$form['end'] = [
    '#type' => 'number',
    '#title' => t('and'),
    '#required' => TRUE,
    '#min' => 1900,
    '#max' => date('Y'),
    '#default_value' => 1999,
    '#value' => 1999,
];

This is a bizarre problem as my attempts to set the #value and #default_value for both the start and end fields are not working.

However, I created the test field and it successfully adds to the form and sets my configured value and default_value.

So, for the start field, I expect to see 1988 as the displayed value but instead that form field displays 1900. The test field I create meanwhile displays and behaves properly ... go figure.

As it is an inherited project, I wonder if there are other means of configuring a form which I am unaware of ?

deleted 28 characters in body
Source Link
sisko
  • 1.7k
  • 1
  • 19
  • 46
Loading
Source Link
sisko
  • 1.7k
  • 1
  • 19
  • 46
Loading