0

我正在构建一个 joomla 组件,但找不到以下解决方案。在我的前端,我使用 joomlas 构建类 JToolbar 来处理点击事件,如编辑、删除等。

            <form action="<?php echo JRoute::_('index.php');?>" method="post"
                name="termForm" id="adminForm">

                <table class="stripeMe">
                    <tbody>


                    <thead>

                        <tr>
                            <th>Begriff</th>
                            <th>Definition</th>



<?php if ($user->authorize('com_glossary', 'edit', 'glossary', 'all')): ?><th>Published</th> <?php endif; ?>    

        </tr>
                    </thead>

              <?php foreach($this->items as $i => $item): ?>

            <tr> 

                <td>

                <span class="title"><?php echo $item->tterm; ?></span>

                    <?php if ($user->authorize('com_glossary', 'edit', 'bearbeiten', 'all')):?> 

                       <?php echo $this->getEdit(); ?><?php endif; ?>

                </td>

               <td><?php echo $item->tdefinition; ?></td>
                 <?php if ($user->authorize('com_glossary', 'edit', 'bearbeiten', 'all')): ?>
               <td><?php echo $this->getPublished(); ?></td> <?php endif; ?>    


           </tr>
               <?php endforeach; ?>

    </tbody>
    </table>

                <div>
        <input type="hidden" name="task" value="" /> <input type="hidden"
                        name="id" value="" onclick="submitbutton(<?php echo count( $item->id ); ?>);" /> <input type="hidden"
                        name="option" value="com_glossary" /> <input type="hidden"
                        name="controller" value="bearbeiten" />


        <?php echo JHtml::_('form.token'); ?>
    </div>
            </form>

我想在按钮事件上将所选行的 id 传递给子控制器,但我真的不知道该怎么做

4

1 回答 1

0

这里有一些关于在前端使用 JToolbar 的有用提示http://docs.joomla.org/How_to_use_the_JToolBar_class_in_the_frontend

我过去做过一次,据我记得我做了一些技巧以使其发挥作用。

1.)首先删除“id”输入并在表单末尾添加以下内容:

<input type="hidden" name="boxchecked" value="0" />

2.) 其次确保 Mootools 已连接到源

3.)最后:在那里,你开始你的 foreach 循环,在“ tr ”标签之后添加另一个表格列:

 <td><?php echo JHTML::_('grid.id', $i, $item->id ); ?></td>

不要忘记在该列中创建列标题

这些步骤将在每行的第一个单元格中创建一个复选框,并使表单能够通过请求发送所选字段的ID

编辑: tbody 标签在错误的位置,它应该在thead标签之后。也没有使用将事件附加到隐藏输入,因为它们不会被触发

干杯

彼得

于 2011-10-25T08:30:09.190 回答