Hi!
I am building a table and I'm trying to integrate some radio buttons in the table row like this:
$row[] = array(
'data' => array(
'#type' => 'radio',
'#title_display' => 'invisible',
'#name' => 'radios_left',
'#return_value' => $vid,
'#default_value' => FALSE,
),
);
but I get the following notice:
Undefined index: #value in /var/www/drupal/core/includes/form.inc on line 1147
However I noticed that if I just display the radio button on it's own (not in a table row) the notice dissapears and also the only way of making the notice dissapear when displaying radio button in a table row is to set the '#value' property.
So, I suppose this is a bug, since I should be able to set default value of radio button without being forced to set the value property.
Comment | File | Size | Author |
---|---|---|---|
#3 | radio-button-default-value-fix-2275837-3.patch | 730 bytes | lhangea |
Comments
Comment #1
lhangea CreditAttribution: lhangea commentedComment #2
Aron NovakThe full code mentioned above is here: http://cgit.drupalcode.org/sandbox-lhangea-2269693/tree/src/Form/Revisio...
Comment #3
lhangea CreditAttribution: lhangea commentedI made a small patch for this.
Comment #4
Aron Novakafterwards the tests, it's surely RTBC
Comment #5
Berdir#value is very likely not set because the form fields are not processed by the form system, as they're hidden away below a #rows, so the forms processing doesn't find them.
In Drupal 7, you had to use a complex approach where you built the form without a table and then added a theme function to render it out as a table, after it was processed by the form API.
in Drupal 8, you can use #type => 'table and then instead of #rows, you can basically add your rows just nested below the table render element. Have a look at https://github.com/md-systems/monitoring/blob/introducing-multigraph/mod... and the following lines.
Try that, I think it will then just work and you can close this issue.
Comment #6
lhangea CreditAttribution: lhangea commentedYep, it works as you said. For those interested: https://www.drupal.org/node/1876710
I will close this issue.
Thanks Berdir
Comment #7
lhangea CreditAttribution: lhangea commented