i need include conditional statement following array called $fields.
$fields = [ 'program_id' => [ 'type' => 'select', 'label' => 'program', 'opts' => ["one", "two", "three"], ], 'name' => [ 'label' => 'job name' ], 'start_date' => [ 'class' => 'date-picker', 'label' => 'job starts' . $req, 'val' => $job->start_date ? datetopicker($job->start_date) : null ], 'end_date' => [ 'class' => 'date-picker', 'label' => 'job ends' . $req, 'val' => $job->end_date ? datetopicker($job->end_date) : null ], 'section' => [ 'type' => 'hidden', 'val' => 'details' ], ]; if (!$job->id && $program) { $fields['job_copy'] = [ 'label' => 'copy job from', 'type' => 'select', 'textasvalue' => false, '_comment' => 'selecting job here copy job information except name.', 'opts' => array_replace([0 => '-- select job --'], $program->jobs()->lists('name', 'id')->all()) ]; } $fields[] = [ 'type' => 'submit', 'label' => "save", 'class' => 'btn btn-primary !important' ];
}
i need move conditional statement top first thing displayed on form. however, when move top disappears. how can integrate conditional check top of form opposed @ bottom displays?
$fields = []; if (!$job->id && $program) { $fields['job_copy'] = [ 'label' => 'copy job from', 'type' => 'select', 'textasvalue' => false, '_comment' => 'selecting job here copy job information except name.', 'opts' => array_replace([0 => '-- select job --'], $program->jobs()->lists('name', 'id')->all()) ]; } $fields2 = [ 'program_id' => [ 'type' => 'select', 'label' => 'program', 'opts' => ["one", "two", "three"], ], 'name' => [ 'label' => 'job name' ], 'start_date' => [ 'class' => 'date-picker', 'label' => 'job starts' . $req, 'val' => $job->start_date ? datetopicker($job->start_date) : null ], 'end_date' => [ 'class' => 'date-picker', 'label' => 'job ends' . $req, 'val' => $job->end_date ? datetopicker($job->end_date) : null ], 'section' => [ 'type' => 'hidden', 'val' => 'details' ], ]; $fields = array_merge($fields,$fields2); $fields[] = [ 'type' => 'submit', 'label' => "save", 'class' => 'btn btn-primary !important' ];
Comments
Post a Comment