0

我有一个使用 xend 框架的 php 表单。我无法获得单选按钮的值

这就是我在控制器中所拥有的

if ($this->getRequest()->isXmlHttpRequest()) {
            if ($this->getRequest()->isPost()) {
                // check session for line and dataset function
                // update queue
                $data = $this->_request->getParams();
        print_r($_POST['locations']);
        exit();
                $this->submitAction();
            }
        }

形式

class Application_Form_LineData extends Zend_Form
{
    private $lineId;
    private $dataId;
    private $name;

    public function init()
    {
        /* Form Elements & Other Definitions Here ... */
    }

    public $elementDecoration = array(
            'ViewHelper',
            //'Description',
            //'Errors',
            array(array('data'=>'HtmlTag'), array('tag' => 'td')),
            //array('Label', array('tag' => 'td')),
            //array('Errors'),
            //array(array('row'=>'HtmlTag'),array('tag'=>'tr'))
    );

    public $elementRowDecoration = array(
            'ViewHelper',
            array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
    );

    public $elementTableDecoration = array(
            'ViewHelper',
            array(array('data' => 'HtmlTag'), array('tag' => 'td')),
            array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
    );

    public $formDecoration = array(
            'FormElements',
            array(array('data'=>'HtmlTag'), array('tag'=>'table', 'class'=>'forms')),
            'Form'
    );


    public function setLineId($lineId)
    {
        $this->lineId = $lineId;
    }

    public function setName($name)
    {
        $this->name = $name;
    }

    public function setDataId($dataId)
    {
        $this->dataId = $dataId;
    }

    public function startform($entries)
    {
        $this->setMethod('post') ->setAttrib('enctype', 'multipart/form-data');

        $count = count($entries);
        for($i=0;$i<$count;$i++){

            $this->addElement('checkbox', 'l_'.$entries[$i]['PGA_Id'], array(
                    'decorators' => $this->elementDecoration,
                    'onclick' => 'updateQueue('.$entries[$i]['PGA_Id'].',false)',

            ));



            // Data sets for each line

            $countData = count($entries[$i]['Data_Set']);
            for($x=0;$x<$countData;$x++){

                $this->addElement('checkbox', 'ds_'.$entries[$i]['Data_Set'][$x]['PGA_Id'], array(
                        'id' => 'ds_'.$entries[$i]['Data_Set'][$x]['PGA_Id'],
                        'decorators' => $this->elementDecoration,
                        'class' => 'line_'.$entries[$i]['PGA_Id'],
                        'onclick' => 'updateQueue('.$entries[$i]['PGA_Id'].','.$entries[$i]['Data_Set'][$x]['PGA_Id'].')',
                        'name' => 'line_'.$entries[$i]['PGA_Id'],

                ));
            }


        }

        $this->addElement('radio', 'locations', array(
                //'label'    => 'Download to: ',
                'multiOptions' => array(
                        'woking'  => 'Woking',
                        'cairo'  => 'Cairo'
                ),
                'decorators' => $this->elementDecoration
        ));

        $this->addElement('submit', 'submit', array(
                'ignore'   => true,
                'label'    => 'Add to queue',
                'decorators' => $this->elementDecoration
        ));

        return $this;
    }
}

我想获取单选框位置的值。

我的观点

<script type="text/javascript">
<!--
$(function() {
    showhide("dataqueue");
});
//-->
</script>

    <!-- display queue for project -->
    <div id="dataqueue">
        <?php echo $this->dataQueueTable($this->queue,$this->qstatus); ?>
    </div>

    <div id="datalist">
    <form method="post">
    <table class=table>
        <tr>
            <!-- <th class="tdid">ID</th> -->
            <th class="tdname">Name</th>
            <!-- <th>Path</th> -->
            <th>Add to Queue</th>
        </tr>
        <?php

        foreach ($this->entries as $entry){ ?>
        <tr class=parent id=<?=$entry['PGA_Id'] ?>>
            <!-- <td><?php echo $entry['PGA_Id'] ?></td> -->
            <td><?php echo $entry['PGA_Name'] ?>    </td>

            <?php //echo $this->form->getElement('l_'.$entry['PGA_Id']) ?>  

            <?php   
            foreach($entry['Data_Set'] as $data){
            ?>
            <tr class=child-<?=$entry['PGA_Id'] ?>>
            <td colspan="3">
            <table class="tdatasets">
                <tr>
                    <!-- <td class="tdid"><?php echo $data['PGA_Id'] ;?></td> -->
                    <td class="subtdname"><?php echo $data['PGA_Name'] ; ?></td>
                    <!-- <td><?php echo $data['PGA_Path'] ; ?></td> -->
                    <?php echo $this->form->getElement('ds_'.$data['PGA_Id']) ?>
                    <td><?php echo $data['size']; ?></td>   
                </tr>
            </table>
            </td>
            </tr>
            <?php } ?>

        </tr>
        <?php } ?>
        <tr>
            <td style="">Download to:</td>
            <?php echo $this->form->getElement('locations') ?>
            <?php echo $this->form->getElement('submit') ?>
        </tr>
    </table>
    </form>
    </div>


    <div id="notification">
        <?php echo $this->notificationTable($this->notification,$this->notificationform); ?>
    </div>
4

2 回答 2

1
$this->getRequest()->getParams();
于 2012-12-04T15:46:18.157 回答
0

我正在使用 ajax 传递表单,花了一整天的时间思考为什么它不起作用。我的错

于 2012-12-03T17:46:18.457 回答