API page: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Database%...
On all api pages for Drupal where addField() is a known function, the description tells you:
Alternatively, the 'initial_form_field' key may be used, which will auto-populate the new field with values from the specified field.
But this doesn't work, and that's because of a simple typo. In the php code itself the spec checks on: if (isset($spec['initial_from_field'])) {
It's a small typo, but when you don't look at the code, but just the description, it will not work:
initial_from_field
initial_form_field
Please update the description to match the code, so people won't think this doesn't work:
$spec: The field specification array, as taken from a schema definition. The specification may also contain the key 'initial', the newly created field will be set to the value of the key in all rows. This is most useful for creating NOT NULL columns with no default value in existing tables. Alternatively, the 'initial_from_field' key may be used, which will auto-populate the new field with values from the specified field.
Comment | File | Size | Author |
---|---|---|---|
#11 | 3295972_9.png | 67.73 KB | Munavijayalakshmi |
#11 | 3295972_6.png | 83.97 KB | Munavijayalakshmi |
#9 | updating-description-3295972-9.patch | 790 bytes | nitin_lama |
#6 | wrong-documentation-initial_from_field-3295972.patch | 8.17 KB | arunkumark |
Issue fork drupal-3295972
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
cilefen CreditAttribution: cilefen as a volunteer commentedComment #3
cilefen CreditAttribution: cilefen as a volunteer commentedComment #4
chaubeyji CreditAttribution: chaubeyji at OpenSense Labs for DrupalFit commentedComment #5
chaubeyji CreditAttribution: chaubeyji at OpenSense Labs for DrupalFit commentedComment #6
arunkumarkActually, this is a typo mistake(
initial_from_field
can be replaced toinitial_form_field
), instead of updating the document we can correct the code level.Created the patch to updating into the code level.
Comment #7
cilefen CreditAttribution: cilefen as a volunteer commentedI disagree:
initial_from_field
is correct.Comment #8
nitin_lamaComment #9
nitin_lamaAdding patch to update the description.
Comment #10
Munavijayalakshmi CreditAttribution: Munavijayalakshmi at Valuebound commentedComment #11
Munavijayalakshmi CreditAttribution: Munavijayalakshmi at Valuebound commentedBoth patches applied successfully.
As per description comment #9 is correct.
As per code level Comment #6 is correct.
Marking this as RTBC.
Comment #12
Munavijayalakshmi CreditAttribution: Munavijayalakshmi at Valuebound commentedComment #15
catchCommitted/pushed to 10.1.x, cherry-picked to 10.0.x/9.5.x/9.4.x, thanks!
@Munavijayalakshmi there's no need to update screenshots to show the patch applying since DrupalCI tests us this directly on the issue. Additionally, there's no need to open an MR if there's a viable patch on the issue - we still use both patches and MRs. Having said this, retained review credit because other steps were taken too.
Comment #16
Krilo_89 CreditAttribution: Krilo_89 as a volunteer and at Synetic commentedThanks @catch!
Didn't had the time to add the MR myself and it actually surprised me, how many people were so fast to add something in this ticket for credits only...
I'm just glad the docs are matching now.
Comment #17
Munavijayalakshmi CreditAttribution: Munavijayalakshmi at Valuebound for Valuebound commentedThanks.