Using codeigniter 4 (PHP) and javascript for the modal. I am trying to pass the value of "rjuid" (html input type hidden) to the controller variable $uid, but I always get NULL value for $uid.
This is my code in view under a modal.
<div class="modal fade" id="RejoinModal" tabindex="-1" role="dialog" aria-labelledby="reJoinModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<?php
$attributes = ['class' => 'frmReJoinUser', 'id' => 'frmRJTUid'];
echo form_open('rejoin_term_user', $attributes);
?>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="reJoinModalLabel">Rejoin User</h4>
</div>
<div class="modal-body">
<?php
$data = [
'type' => 'hidden',
'name' => 'rjuid',
'id' => 'rjuid',
'value' => '',
'class' => 'form-control',
];
echo form_input($data);
?>
<div class="form-group">
<label for="rejoin_date">Rejoin Date:</label>
<input type="date" class="form-control" id="rejoin_date" placeholder="Enter Rejoin Date" name="rejoin_date" required>
</div>
<div class="form-group">
<label for="name">Remarks (if any):</label>
<textarea rows="2" cols="50" class="form-control" id="remarks" placeholder="Enter Remarks" name="remarks"></textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-bs-dismiss="modal">Close</button>
<button type="submit" id='btnReJoinTermUser' class="btn btn-primary">Rejoin user</button>
</div>
<?php echo form_close(); ?>
</div>
</div>
</div>
This is my controller (rejoin_term_user.php)
public function rejoin_term_user(){
$request = \Config\Services::request();
echo "<h1> Rejoin Term </h1>";
$uid = $request->getPost('rjuid');
// $uid = $this->request->getPost('rjuid');
// $uid = $this->request->getVar('rjuid');
// $uid = $this->request->getPostGet('rjuid');
dd($uid);
}
Note: I already tried those codes that are commented in the controller, but still I get Null value for $uid.