【问题标题】:how to take css information in symfony2 form for radio buttons如何以 symfony2 形式获取单选按钮的 css 信息
【发布时间】:2018-04-11 15:34:34
【问题描述】:

我正在用 Symfony 重写一个表单。

在旧的 php 页面中,有类似这张图片的内容。 代码如下所示:

<tr>
                                            <td width="10%" class="form_content2"></td>
                                            <td width="16%"><em>Suspected CP</em></td>
                                            <td width="4%"><input id="FU1_CP_suspect" type="checkbox"
                                                                  tabindex="64" name="FU1_CP_suspect" value="1"
                                                                  <?php if (show($patient, 'D_FU1::FU1_CP_suspect') == "1") { ?>
                                                                      checked="checked" <?php } ?>></td>
                                            <td width="70%" colspan="6">(= child will be assessed for CP again at a
                                                later date)</td>
                                        </tr>
                                        <tr>
                                            <td width="10%" class="form_content2"></td>
                                            <td width="36%" colspan="3">&nbsp;</td>
                                            <td width="4%" align="center">L</td>
                                            <td width="4%" align="center">R</td>
                                            <td width="46%" colspan="3">&nbsp;</td>
                                        </tr>
                                        <tr>
                                            <td width="10%" class="form_content2"></td>
                                            <td width="16%" valign="top" rowspan="6"><i>Spastic CP</i></td>
                                            <td width="4%"><input id="SPcp1" type="radio" tabindex="64"
                                                                  name="FU1_Spastic_CP" value="1"
                                                                  <?php if (show($patient, 'D_FU1::FU1_Spastic_CP') == "1") { ?>
                                                                      checked="checked" <?php } ?> /></td>
                                            <td width="16%">Monoplegia</td>
                                            <td width="4%"><input id="SPcp2" type="radio" tabindex="65"
                                                                  name="FU1_Monoplegia_LR" value="1"
                                                                  <?php if (show($patient, 'D_FU1::FU1_Monoplegia_LR') == "1") { ?>
                                                                      checked="checked" <?php } ?> />
                                            </td>
                                            <td width="4%"><input id="SPcp3" type="radio" tabindex="66"
                                                                  name="FU1_Monoplegia_LR" value="2"
                                                                  <?php if (show($patient, 'D_FU1::FU1_Monoplegia_LR') == "2") { ?>
                                                                      checked="checked" <?php } ?> />
                                            </td>
                                            <td width="16%" valign="top"><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dyskinetic
                                                    CP</i></td>
                                            <td width="4%"><input id="SPcp4" type="radio" tabindex="73"
                                                                  name="FU1_Dyskinetic_CP" value="1"
                                                                  <?php if (show($patient, 'D_FU1::FU1_Dyskinetic_CP') == "1") { ?>
                                                                      checked="checked" <?php } ?> />
                                            </td>
                                            <td width="26%">Dystonic</td>
                                        </tr>
                                        <tr>
                                            <td width="10%" class="form_content2"></td>
                                            <td width="4%"><input id="SPcp5" type="radio" tabindex="67"
                                                                  name="FU1_Spastic_CP" value="2"
                                                                  <?php if (show($patient, 'D_FU1::FU1_Spastic_CP') == "2") { ?>
                                                                      checked="checked" <?php } ?>>
                                            </td>
                                            <td width="40%" colspan="4">Diplegia*<br>
                                            </td>
                                            <td width="4%"><input id="SPcp6" type="radio" tabindex="74"
                                                                  name="FU1_Dyskinetic_CP" value="2"
                                                                  <?php if (show($patient, 'D_FU1::FU1_Dyskinetic_CP') == "2") { ?>
                                                                      checked="checked" <?php } ?>></td>
                                            <td width="26%">Choreoathetotic</td>
                                        </tr>
                                        <tr>
                                            <td width="10%" class="form_content2"></td>
                                            <td width="4%"><input id="SPcp7" type="radio" tabindex="68"
                                                                  name="FU1_Spastic_CP" value="3"
                                                                  <?php if (show($patient, 'D_FU1::FU1_Spastic_CP') == "3") { ?>
                                                                      checked="checked" <?php } ?>>
                                            </td>
                                            <td width="70%" colspan="6">Triplegia<br>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td width="10%" class="form_content2"></td>
                                            <td width="4%"><input id="SPcp8" type="radio" tabindex="69"
                                                                  name="FU1_Spastic_CP" value="4"
                                                                  <?php if (show($patient, 'D_FU1::FU1_Spastic_CP') == "4") { ?>
                                                                      checked="checked" <?php } ?>>
                                            </td>
                                            <td width="16%">Hemiplegia</td>
                                            <td width="4%"><input id="SPcp9" type="radio" tabindex="70"
                                                                  name="FU1_Hemiplegia_LR" value="1"
                                                                  <?php if (show($patient, 'D_FU1::FU1_Hemiplegia_LR') == "1") { ?>
                                                                      checked="checked" <?php } ?>>
                                            </td>
                                            <td width="4%"><input id="SPcp10" type="radio" tabindex="71"
                                                                  name="FU1_Hemiplegia_LR" value="2"
                                                                  <?php if (show($patient, 'D_FU1::FU1_Hemiplegia_LR') == "2") { ?>
                                                                      checked="checked" <?php } ?>>
                                            </td>
                                            <td width="16%" valign="top"><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Ataxic
                                                    CP</i></td>
                                            <td width="4%"><input id="SPcp11" type="radio" tabindex="75"
                                                                  name="FU1_Ataxic_CP" value="1"
                                                                  <?php if (show($patient, 'D_FU1::FU1_Ataxic_CP') == "1") { ?>
                                                                      checked="checked" <?php } ?>></td>
                                            <td width="26%">Ataxia</td>
                                        </tr>
                                        <tr>
                                            <td width="10%" class="form_content2"></td>
                                            <td width="4%"><input id="SPcp12" type="radio" tabindex="72"
                                                                  name="FU1_Spastic_CP" value="5"
                                                                  <?php if (show($patient, 'D_FU1::FU1_Spastic_CP') == "5") { ?>
                                                                      checked="checked" <?php } ?> />
                                            </td>
                                            <td colspan="4" width="40%">Tetraplegia<br>
                                            </td>
                                            <td width="4%"><input id="SPcp13" type="radio" tabindex="76"
                                                                  name="FU1_Ataxic_CP" value="2"
                                                                  <?php if (show($patient, 'D_FU1::FU1_Ataxic_CP') == "2") { ?>
                                                                      checked="checked" <?php } ?> />
                                            </td>
                                            <td width="26%">Hemiataxia</td>
                                        </tr>
                                        <tr>
                                            <td width="10%" class="form_content2"></td>
                                            <td width="4%"><input id="SPcp14" type="radio" tabindex="77"
                                                                  name="FU1_Spastic_CP" value="6"
                                                                  <?php if (show($patient, 'D_FU1::FU1_Spastic_CP') == "6") { ?>
                                                                      checked="checked" <?php } ?>>
                                            </td>
                                            <td colspan="6" width="70%">unknown form of CP<br>
                                            </td>
                                        </tr>
                                        <td width="10%" class="form_content2"></td>
                                        <td width="90%" colspan="8">*Diplegia = bilateral predominant
                                            tetraspasticity</td>
                                        <tr>
                                            <td width="10%" class="form_content2"></td>
                                            <td width="90%" colspan="8"></td>
                                        </tr>
                                        <tr>
                                            <td width="10%" class="form_content2"></td>
                                            <td width="16%" valign="top" rowspan="6"><i>Degree of CP** (according to <a href="../pdf/GMFCS-ER_English.pdf" target="_blank">GMFCS Palisano scheme)</a>
                                                </i></td>
                                            <td width="4%"><input id="cpdegree0" type="radio" tabindex="80"
                                                                  name="FU1_CP_Degree" value="0"
                                                                  <?php if (show($patient, 'D_FU1::FU1_CP_Degree') == "0") { ?>
                                                                      checked="checked" <?php } ?>>
                                            </td>
                                            <td width="70%" colspan="6">Normal (note that child therefore does not qualify for CP)</td>
                                        </tr>
                                        <tr>
                                            <td width="10%" class="form_content2"></td>
                                            <td width="4%"><input id="cpdegree1" type="radio" tabindex="81"
                                                                  name="FU1_CP_Degree" value="1"
                                                                  <?php if (show($patient, 'D_FU1::FU1_CP_Degree') == "1") { ?>
                                                                      checked="checked" <?php } ?>>
                                            </td>
                                            <td width="70%" colspan="6">Level 1</td>
                                        </tr>
                                        <tr>
                                            <td width="10%" class="form_content2"></td>
                                            <td width="4%"><input id="cpdegree2" type="radio" tabindex="82"
                                                                  name="FU1_CP_Degree" value="2"
                                                                  <?php if (show($patient, 'D_FU1::FU1_CP_Degree') == "2") { ?>
                                                                      checked="checked" <?php } ?>>
                                            </td>
                                            <td width="70%" colspan="6">Level 2</td>
                                        </tr>
                                        <tr>
                                            <td width="10%" class="form_content2"></td>
                                            <td width="4%"><input id="cpdegree3" type="radio" tabindex="83"
                                                                  name="FU1_CP_Degree" value="3"
                                                                  <?php if (show($patient, 'D_FU1::FU1_CP_Degree') == "3") { ?>
                                                                      checked="checked" <?php } ?>>
                                            </td>
                                            <td width="70%" colspan="6">Level 3</td>
                                        </tr>
                                        <tr>
                                            <td width="10%" class="form_content2"></td>
                                            <td width="4%"><input id="cpdegree4" type="radio" tabindex="84"
                                                                  name="FU1_CP_Degree" value="4"
                                                                  <?php if (show($patient, 'D_FU1::FU1_CP_Degree') == "4") { ?>
                                                                      checked="checked" <?php } ?>>
                                            </td>
                                            <td width="70%" colspan="6">Level 4</td>
                                        </tr>
                                        <tr>
                                            <td width="10%" class="form_content2"></td>
                                            <td width="4%"><input id="cpdegree5" type="radio" tabindex="85"
                                                                  name="FU1_CP_Degree" value="5"
                                                                  <?php if (show($patient, 'D_FU1::FU1_CP_Degree') == "5") { ?>
                                                                      checked="checked" <?php } ?>>
                                            </td>
                                            <td width="70%" colspan="6">Level 5</td>
                                        </tr>
                                        <tr>
                                            <td width="10%" class="form_content2"></td>
                                            <td width="90%" colspan="8">**(determine the LEVEL that most
                                                closely describes the child's current GROSS MOTOR FUNCTION
                                                according to GMFCS Palisano scheme)
                                            </td>
                                        </tr>
                                    </table>

在 FU1_Spastic_CP 的不同值中保存了 Monoplegia、Diplegia 等...这些可以随意放置在任何地方,因为它们没有被定义为一个块。

但在 Symfony 中,我将这些不同的选择 Monoplegia、Diplegia... 都与 formbuilder 一起声明,但我不知道如何修改它们中的每一个的位置。

$builder

    ->add('fu1SpasticCp', 'choice', array(
      'choices'=> array(
      'Monoplegia'=1,
      'Diplegia'=2,
      'Triplegia'=3,
      'Hemiplegia'=4,
      'Tetraplegia'=5,
      'unknown form of CP'=6),
      'choices_as_values'=> true,
      'expanded' => true
    ))

感谢您的建议!

【问题讨论】:

    标签: php css symfony


    【解决方案1】:

    我认为您正在寻找类似的东西: symfony3-how-to-separate-radio-buttons-from-a-choicetype

    记住,它是一个数组。:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-24
      • 1970-01-01
      • 2023-04-07
      • 2012-03-12
      • 2014-02-21
      • 2014-04-12
      • 2011-07-28
      • 2023-04-11
      相关资源
      最近更新 更多