Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
API page: http://api.drupal.org/api/drupal/developer--topics--forms_api_reference....
See http://drupal.org/node/342316#comment-4732130 for an extremely useful behaviour which is largely unknown.
Comment | File | Size | Author |
---|---|---|---|
#20 | checkboxes.png | 44.47 KB | shashikant_chauhan |
#20 | radios.png | 54.08 KB | shashikant_chauhan |
#20 | 1349432-20.patch | 12.55 KB | shashikant_chauhan |
#16 | 1349432-16.patch | 14.93 KB | shashikant_chauhan |
#16 | checkboxes.png | 44.86 KB | shashikant_chauhan |
Comments
Comment #1
jhodgdonMoving to documetation queue (the file to be edited is in that git repository).
Comment #2
jhodgdonTagging so #1421874: [meta] Documentation Issue Queue Cleanup doesn't have to look at API docs issues.
Comment #3
jhodgdontagging
Comment #4
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedLinking to the Drupal 8 version of this. The patch here could use similar text as that one does.
Comment #5
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedComment #6
shashikant_chauhan CreditAttribution: shashikant_chauhan as a volunteer and at Iksula commentedI am unable to find starting point where I can make changes so that it is reflected in developer/topics/forms_api_reference.html
Comment #7
joachim CreditAttribution: joachim commentedIt's the file developer/topics/forms_api_reference.html in the repo for this project. 7.x-1.x branch, I assume.
Comment #8
shashikant_chauhan CreditAttribution: shashikant_chauhan as a volunteer and at Iksula commentedUnable to find such file "forms_api_reference.html" in drupal 7.x repo. Not sure if I am looking at a right place or not.
Comment #9
joachim CreditAttribution: joachim commentedNot in the Drupal repo, in the repo for *this* project. This issue is not under the Drupal project! Click the tab that says 'Documentation' that's just above the breadcrumb.
Comment #10
shashikant_chauhan CreditAttribution: shashikant_chauhan as a volunteer and at Iksula commentedAdding patch
Comment #11
shashikant_chauhan CreditAttribution: shashikant_chauhan as a volunteer and at Iksula commentedScreenshots after applying the patch.
Comment #12
xeM8VfDh CreditAttribution: xeM8VfDh commentedThank you VERY much @joachim and @sun for pointing out this useful behavior!
Comment #13
jhodgdonCan someone test the code in the proposed changes (see screenshot) and verify that it works correctly in a D7 form? Thanks!
Comment #14
joachim CreditAttribution: joachim as a volunteer commentedThe adding of extra options looks ok, but there is a problem with the main form element that's being added: drupal_map_assoc() should not be used with translated values, as it means the stored keys will be different in different languages! Only the option labels should be translated.
(Also, is there any way that line breaks could be added to the source, as it's really hard to read it on very long lines.)
Comment #15
jhodgdonFeel free to add line breaks to the file.
Comment #16
shashikant_chauhan CreditAttribution: shashikant_chauhan as a volunteer and at Iksula commented@joachim, I have removed the function "drupal_map_assoc" from docs.
After applying patch.
Radios:
Checkboxes
Comment #17
jhodgdonBy splitting the code line up into multiple lines, your patch has added a bunch of whitespace that shouldn't be on the page. For instance, it should look like
not
There should not be spaces around the (). Same with [].
Also because of splitting the lines, it is very difficult to look at the patch and see what has actually changed from the old version. It looks like the whole thing is completely different, but it actually isn't.
So... please make a new patch. Thanks!
Comment #18
shashikant_chauhan CreditAttribution: shashikant_chauhan as a volunteer and at Iksula commented@jhodgdon, These whitespaces are added due to new line breaks. After removing those new line break it will look like
t('whatever')
Eg: https://jsfiddle.net/shashi1028/e1Ltukn8/
Or should I create patch like
to remove spaces.
Comment #19
jhodgdonYes, I understood that the line breaks generated the extra spaces. Please remove them, rather than adding comments.
Why do I say this? Well, ... It is a general philosophy in the Drupal project as a whole, that patches should only address the actual problem in the issue. So, if you have an issue that says "We should add to this documentation an example showing how to set options", you should make a patch that does just that. Not a patch that also totally reformats that section of the file.
So, if you want to make a patch that reformats a file, you should use a separate issue to do that, not combine it with this issue.
Thanks!
Comment #20
shashikant_chauhan CreditAttribution: shashikant_chauhan as a volunteer and at Iksula commentedHere is the new patch after removing line breaks.
Comment #21
bbombachiniThe patch applied evenly and seems good. Moving it to reviewed.
Comment #22
apaderno