如何在codeIgniter表单助手中编写php代码

时间:2017-08-24 10:00:02

标签: php codeigniter

我正在尝试使用相同的视图进行编辑和创建

想要实现这个目标

<form role="form" enctype="multipart/form-data" id="form"
                                  action="<?php echo base_url(); ?>admin/leads/saved_call/<?= $leads_details->leads_id ?>/<?php
                                  if (!empty($call_info)) {
                                      echo $call_info->calls_id;
                                  }
                                  ?>" method="post" class="form-horizontal  ">

使用此表单助手

 <?= form_open_multipart("leads/Leads/createCall/$LeadDetail->leads_id/if(!empty($call_info->calls_id)){echo $call_info->calls_id}") ?>

如何在codeignitor中形成帮助条件

2 个答案:

答案 0 :(得分:1)

在变量中设置值并回显它,

 <?php
    if(!empty($call_info->calls_id)){ $cinfo = $call_info->calls_id; } else { $cinfo = '';} ?>
    <?= form_open_multipart("leads/Leads/createCall/$LeadDetail->leads_id/".$cinfo."") 
    ?>

答案 1 :(得分:0)

尝试以下代码:

<?= form_open_multipart("leads/Leads/createCall/$LeadDetail->leads_id/(!empty($call_info->calls_id)) ? echo $call_info->calls_id; : ''") ?>