根据条件显示选择框在zend中

时间:2018-10-22 07:26:50

标签: php zend-framework

嗨,我正在尝试在没有网格对象时显示选择框。如果我现在有网格,它将不会显示该选择框。 但就我而言,我想在网格对象也出现时显示选择框

像下面一样

enter image description here

这是我的查看页面代码:

<div>
<?php
if (!empty($this->ticketGridObject)) :
    echo $this->headScript();
    echo $this->ticketGridObject;
else :
?>
<span class="order-ticket-source-text">
    <label><?php echo $this->translate('ticket_source_led_to_order');?> : </label>
</span>

<span class="order-ticket-source-select">
    <select id="ticketSource">
        <option value="">--<?php echo $this->translate('select') ?>--</option>
        <?php foreach ($this->ticketSources as $ticketSource) : ?>
            <option value="<?php echo $ticketSource->source ;?>"><?php echo $ticketSource->source;?></option>
        <?php endforeach;?>
    </select>
</span>
<span class="source-add-icon js-add-new-ticket">
    <img src="/themes/bas/icons/fatcow/16x16/add.png"/>
</span>
<?php endif; ?>

这是我的控制器代码:

 /**
 * Get order ticket details
 */
public function ticketDetailsAction()
{
    $orderId = $this->getRequest()->getParam('orderId', 0);
    $contactId = $this->getRequest()->getParam('contactId', 0);
    $bootstrap = $this->getInvokeArg('bootstrap');
    $ticketService = new Tickets_Service_Ticket($bootstrap->getOptions());
    $userId = $this->getUserInfo()->getId();
    $params = array(
        'depotAndAffiliateIds' => array_keys($this->_affiliatedDepotMastersWithActiveDepot),
        'orderId' => $orderId,
        'contactId' => (int)$contactId,
        'user' => $userId,
    );
    $options = array(
        'language' => BAS_Shared_Model_Ticket::LANGUAGE_DEFAULT,
        'user' => $userId,
        'translate' => $bootstrap->getResource('translate'),
        'config' => $bootstrap->getResource('config'),
    );
    $ticketGridService = new Ticket_Service_Grid($ticketService, $options);
    if (0 < (int)$contactId) {
        $this->view->ticketGridObject =  $ticketGridService->getGrid(Ticket_Service_Grid::GRID_TYPE_ORDERTICKETOVERVIEW, $params);
    }
    if (empty($this->view->ticketGridObject)) {
        $where = array('depot_id in (?)' => array_keys($this->_affiliatedDepotMastersWithActiveDepot));
        $this->view->ticketSources = $ticketService->getTicketSourceList($where);
    }
}

谁能帮我 我该怎么办。谢谢。

0 个答案:

没有答案