cara agar input data kosong di controllers dan di view outputnya tetap kosong

saya ada kendala, saat input angka 0 (nol) di controller sudah berhasil tersimpan namun di view muncul outputnya kosong. agar di view outputnya juga 0 (nol) bagaimana ya?

kesalahan atau kekurangannya dimana?

soalnya kalau diinput tanda - atau n/a masih bisa muncul di view.

source code view

<div class="panel panel-default">
	<div class="panel-heading">
		<h4>Data Strategis (<?=$dari." - ".$sampai;?>)</h4>
	</div>

	<div class="panel-body">
		<div class="row">
			<div class="col-md-12">
				<div class="panel panel-default">
					<div class="panel-body">
						<form action="<?=base_url('lihat/statistik_strategis');?>" method="get" class="form">
							<div class="col-md-2"><?=form_dropdown("dari",$p_tahun,$dari,'class="form-control" required id="dari"');?></div>
							<div class="col-md-1"><label for="">Sampai Dengan</label></div>
							<div class="col-md-2"><?=form_dropdown("sampai",$p_tahun,$sampai,'class="form-control" required id="sampai"');?></div>
							<div class="col-md-1"><label for="">Kata Kunci</label></div>
							<div class="col-md-3"><?=form_input("q",$this->input->get('q'),'class="form-control"');?></div>
							<div class="col-md-1"><button type="submit" class="btn btn-success"><i class="fa fa-search"></i></button></div>
						</form>
					</div>
				</div>
			</div>
		</div>

		<?=$html;?>

		<div style="margin-bottom: 20px">
			<p>*) Sumber : Badan Pusat Statistik Kulon Progo</p>
			Keterangan Tabel :<br>
			<div style="padding: 10px; display: inline; float: left; border: solid 1px #222; margin-right: 10px; background: #9af38a"></div>
			<div style="display: inline; float: left; margin-right: 20px"> Angka Sementara  </div>
			<div style="padding: 10px; display: inline; float: left; border: solid 1px #222; margin-right: 10px; background: #909cf7"></div>
			<div style="display: inline; float: left; margin-right: 20px"> Angka Sangat Sementara </div>
		</div>
	</div>
</div>

<!-- DATA PUBLIKASI BPS  -->
<div class="modal fade" id="ModalGrafikDataStrategis" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title" id="myModalLabel">Grafik</h4>
			</div>
			<div class="modal-body">
				<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
			</div>
		</div>
	</div>
</div>

<script type="text/javascript">
	// view_graf('.$dr['id'].', '.$d['dari'].', '.$d['sampai'].')

	function view_graf(id, dari, sampai)
	{
		if($valu=='0.0000') {
                $valu   = "";

		$("#ModalGrafikDataStrategis").modal('show');

		$.ajax({
		    type: "POST",
		    data: {idelemen: id, dari: dari, sampai: sampai},
		    url: base_url+"lihat/ss_grafik",
		    success: function(r, textStatus, jqXHR) {

		    	Highcharts.chart('container', {
				    chart: {
				        type: 'column'
				    },
				    title: {
				        text: r.title
				    },
				    xAxis: {
				        categories: r.tahun,
				        crosshair: true
				    },
				    yAxis: {
				        min: 0,
				        title: {
				            text: 'Jumlah ('+r.satuan+')'
				        }
				    },
				    tooltip: {
				        headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
				        pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
				            '<td style="padding:0"><b>{point.y:f} '+r.satuan+'</b></td></tr>',
				        footerFormat: '</table>',
				        shared: true,
				        useHTML: true
				    },
				    plotOptions: {
				        column: {
				            pointPadding: 0.2,
				            borderWidth: 0
				        }
				    },
				    series: r.data
				});
		    },
		    error: function(xhr) {
				alert(xhr);
		    }
		});
		return false;
	}
</script>

source code controllers

public function input_detil() {

        $p = $this->input->get();

        if (array_key_exists("is_only_statistik_update", $p)) {
            $url_new = base_url('index.php/statistik_strategis/input_detil?'.http_build_query($p));
        } else {
            $url_new = base_url('index.php/statistik_strategis/input_detil?'.http_build_query($p)."&is_only_statistik_update=1");
        }

        $this->db->where('tahun', $p['tahun']);
        $get_data = $this->db->get('data_statistik_strategis_data')->result_array();

        $tampung_data_detil = array();

        if (!empty($get_data)) {
            foreach ($get_data as $data_detil) {
                $idx1 = $data_detil['id_ref'];
                $idx2 = $data_detil['tahun'];

                $tampung_data_detil[$idx1][$idx2]['val'] = $data_detil['isi'];
                $tampung_data_detil[$idx1][$idx2]['status'] = $data_detil['status_data'];
            }
        }

        // get elemen
        $this->db->order_by('kode1', 'asc');
        $this->db->order_by('kode2', 'asc');
        if (!empty($p['is_only_statistik_update'])) {
            if ($p['is_only_statistik_update'] == 1) {
                $this->db->where('sebagai_statistik_update', 1);
            }
        }
        $get_elemen = $this->db->get('data_statistik_strategis_ref')->result_array();

        $html = '<table class="table table-bordered table-condensed">
                <thead>
                    <tr>
                        <th>Nama</th>
                ';
        // foreach ($p['tahun'] as $t) {
            $html .= '<th>' . $p['tahun'] . '</th>';
            $html .= '<th>Status Data</th>';
            // $html .= '<th>' . $t . '</th>';
        // }

        $html .= '</tr></thead><tbody>';

        foreach ($get_elemen as $g) {
            $nama = '<b><i>'.$g['nama'].'</i></b>';

            if ($g['kode1'] != "0" && $g['kode2'] != "0" && $g['kode3'] == "0") {
                $nama = '<div style="margin-left: 40px">'.$g['nama'].'</div>';
            } else if ($g['kode1'] != "0" && $g['kode2'] != "0" && $g['kode3'] != "0") {
                $nama = '<div style="margin-left: 80px; text-transform: uppercase; font-weight: bold">'.$g['nama'].'</div>';
            }

            $html .= '<tr><td>' . $nama . '</td>';

            $valu       = "";
            $stat       = "";
            $idx_elemen = $g['id'];
            $t = $p['tahun'];
            $idx_tahun  = $t;

            if (!empty($tampung_data_detil[$idx_elemen][$idx_tahun]['val'])) {
                $valu = $tampung_data_detil[$idx_elemen][$idx_tahun]['val'];
            }
            if (!empty($tampung_data_detil[$idx_elemen][$idx_tahun]['status'])) {
                $stat = $tampung_data_detil[$idx_elemen][$idx_tahun]['status'];
            }

            if($valu=='0.0000') {
                $valu   = "";
            }
            if (($g['kode1'] != "0" && $g['kode2'] == "0") || $g['mode_terhadap_child'] == 0) {
                $html .= '<td><input type="text" style="text-align: right" name="data[' . $g['id'] . '][' . $t . '][val]" class="form-control input-sm" value="' . $valu . '"></td>';
                $html .= '<td>'.form_dropdown('data['.$g['id'].']['.$t.'][status]', array("1"=>"OK","2"=>"Angka Sementara","3"=>"Angka Sangat Sementara"), $stat, 'class="form-control input-sm"').'</td>';

            } else {
                $html .= '<td>&nbsp;</td><td>&nbsp;</td>';
            }

            $html .= '</tr>';
        }

        $html .= '<tr><th colspan="3"><button type="submit" id="tbSubmit" class="btn btn-success">Simpan</button> <a href="' . base_url('index.php/statistik_strategis') . '" class="btn btn-danger">Kembali</a></th></tr></tbody></table>';

        $d['url_new']   = $url_new;
        $d['p']         = "view_form";
        $d['html_form'] = $html;
        $d['js'] = ["statistik_strategis_detil.js"];
        $d['menu_aktif'] = 3;
        $d['title']     = "Input Statistik Strategis";
        $d['bredkum']   = bredkum(array("statistik_strategis" => $d['title']), "statistik_strategis");
        $this->load->view('template', $d);
    }

ss admin

https://imgur.com/b6XxxPc

ss view

https://imgur.com/SCNSunk

avatar azimatulkhusniah
@azimatulkhusniah

5 Kontribusi 4 Poin

Dipost 3 tahun yang lalu

Tanggapan

bertanya dengan baik,. apa yang kamu tanyakan, jelaskan kodenya, jangan hanya copy paste kodenya, orang lain tidak bisa langsung mengerti kode kamu

baik kak, terimakasih. :)

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban