I'm creating a web back end for a restaurant. There is an option to block/unblock restaurant owners. I have put an "if" condition to appear button (a tag) according to the status of the restaurant owner. Within this "a" tag I want to pass the value (id) to a modal box.
I put some code in the "data-target" of "a" tag, as well as in the modal id. The value didn't pass and also didn't open the modal.
<tbody>
<?php
global $con;
$sql = "SELECT * FROM `fd_owner_details`";
$result=mysqli_query($con,$sql);
while($row=mysqli_fetch_array($result,MYSQLI_ASSOC)){
$kk=$row['id'];
?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['fname']. " " .$row['lname'] ; ?></td>
<td><?php echo $row['address_line1']. ", " .$row['address_line2'] ; ?></td>
<td><?php echo $row['contact_no1'].", ".$row['contact_no2']; ?></td>
<td><?php echo '<img src= "'.$row['image'].'">'; ?></td>
<td>
<?php
if ($row['status']==1){
echo "<span class='label mb-2 mb-xl-0 label-dark'>Active</span>";
}
else {
echo "<span class='label mb-2 mb-xl-0 label-light'>Disabled</span>";
}
?>
</td>
<td>
<span>
<i class="fa fa-pencil" aria-hidden="true"></i>
<?php
if ($row['status']==1){
echo '<i class="fa fa-ban" aria-hidden="true"></i>';
}
else {
echo "<a href='#' data-toggle='modal' data-target='#unblockRestaurantOwner' class='btn btn-warning btn-xs' data-toggle='tooltip' data-placement='top' data-original-title='Unblock'><i class='fa fa-check' aria-hidden='true'></i></a>";
}
?>
<i class="fa fa-trash" aria-hidden="true"></i>
</span>
</td>
</tr>
<?php } ?>
</tbody>
--------------------------------------------------------------------------------
<div class="modal fade" id="blockRestaurantOwner?id=<?php echo $row['id']; ?>" tabindex="-1" role="dialog" aria-labelledby="blockRestaurantOwnerTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Confirm Delete </h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">× </span>
</button>
</div>
<div class="modal-body">
<p id="main-content">Are you sure you want to block this restaurant owner ???</p>
<p id="content">You will not be able to recover this action !!!</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">No, Cancel it </button>
<button type="button" class="btn btn-warning">Yes, Block</button>
</div>
</div>
</div>
</div>
Where Should I change, to get the "id" to the modal ?
Just copy the whole script and try to past inside a php file and try to run it. This can be modified as expected at your end using while loop.
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
</head>
<?php
$array[] = array('id'=>1, 'fname'=>'hari','lname'=>'ltest','address_line1'=>'no:9','address_line1'=>'rajan street','contact_no1'=>'92222','contact_no2'=>'899782','status'=>1);
$array[] = array('id'=>2, 'fname'=>'vvvv','lname'=>'ltest2','address_line1'=>'no:92','address_line1'=>'siv street','contact_no1'=>'522','contact_no2'=>'2922','status'=>0);
?>
<table border=1>
<tbody>
<?php foreach($array as $row){ ?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['fname']. " " .$row['lname'] ; ?></td>
<td><?php echo $row['address_line1']. ", " .$row['address_line2'] ; ?></td>
<td><?php echo $row['contact_no1'].", ".$row['contact_no2']; ?></td>
<td>
<?php
if ($row['status']==1){
echo "<span class='label mb-2 mb-xl-0 label-dark'>Active</span>";
}
else {
echo "<span class='label mb-2 mb-xl-0 label-light'>Disabled</span>";
}
?>
</td>
<td>
<span>
<i class="fa fa-pencil" aria-hidden="true"></i>
<?php if ($row['status']==1){ ?>
<a data-toggle="modal" href="#blockRestaurantOwner<?=$row['id']?>" class="btn btn-warning btn-xs" data-toggle="tooltip" data-placement="top" data-original-title="Block"><i class="fa fa-ban" aria-hidden="true"></i></a>
<div id="blockRestaurantOwner<?php echo $row['id']; ?>" class="modal fade" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Confirm Delete </h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">× </span>
</button>
</div>
<div class="modal-body">
<p id="main-content">Are you sure you want to block this restaurant owner ???</p>
<p id="content">You will not be able to recover this action !!!</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">No, Cancel it </button>
<button type="button" class="btn btn-warning">Yes, Block</button>
</div>
</div>
</div>
</div>
<?php }
else {
echo "<a href='#' data-toggle='modal' data-target='#unblockRestaurantOwner' class='btn btn-warning btn-xs' data-toggle='tooltip' data-placement='top' data-original-title='Unblock'><i class='fa fa-check' aria-hidden='true'></i></a>";
}
?>
<i class="fa fa-trash" aria-hidden="true"></i>
</span>
</td>
</tr>
<?php } ?>
</tbody>
</table>
you can set onclick listener to block button and pass owner id to that function like below
<tbody>
<?php
global $con;
$sql = "SELECT * FROM `fd_owner_details`";
$result=mysqli_query($con,$sql);
while($row=mysqli_fetch_array($result,MYSQLI_ASSOC)){
$kk=$row['id'];
?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['fname']. " " .$row['lname'] ; ?></td>
<td><?php echo $row['address_line1']. ", " .$row['address_line2'] ; ?></td>
<td><?php echo $row['contact_no1'].", ".$row['contact_no2']; ?></td>
<td><?php echo '<img src= "'.$row['image'].'">'; ?></td>
<td>
<?php
if ($row['status']==1){
echo "<span class='label mb-2 mb-xl-0 label-dark'>Active</span>";
}
else {
echo "<span class='label mb-2 mb-xl-0 label-light'>Disabled</span>";
}
?>
</td>
<td>
<span>
<i class="fa fa-pencil" aria-hidden="true"></i>
<?php
if ($row['status']==1){
echo '<i class="fa fa-ban" aria-hidden="true"></i>';
}
else {
echo "<a href='#' data-toggle='modal' data-target='#unblockRestaurantOwner' class='btn btn-warning btn-xs' data-toggle='tooltip' data-placement='top' data-original-title='Unblock'><i class='fa fa-check' aria-hidden='true'></i></a>";
}
?>
<i class="fa fa-trash" aria-hidden="true"></i>
</span>
</td>
</tr>
<?php } ?>
</tbody>
<div class="modal fade" id="blockRestaurantOwner" tabindex="-1" role="dialog" aria-labelledby="blockRestaurantOwnerTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Confirm Delete </h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">× </span>
</button>
</div>
<div class="modal-body">
<p id="main-content">Are you sure you want to block this restaurant owner ???</p>
<p id="content">You will not be able to recover this action !!!</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">No, Cancel it </button>
<button type="button" class="btn btn-warning">Yes, Block</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var target_owner_id="";
function set_target_id(id){
target_owner_id = id;
console.log(target_owner_id);
}
</script>
Related
Currently i have a table that is generated via DB and i want to view the details of the selected value on the data table. I separated the modal with view/users/modal. but there's an error
Message: Trying to get property 'user_id' of non-object
please help me to resolve this
I am running Codeigniter 3.1.10
Xampp V3.2.3
Data Table
<?php echo $this->load->view('users/Modal/view_modal'); ?>
<tbody>
<?php if(!empty($value)): ?>
<?php foreach($value as $row): ?>
<tr>
<td align="center"><?php echo $row->user_id; ?></td>
<td align="center"><?php echo $row->firstname; ?></td>
<td align="center"><?php echo $row->lastname; ?></td>
<td align="center"><?php echo $row->email; ?></td>
<td align="center">
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#info_modal<?php echo $row->user_id; ?>">
<i class="far fa-eye"></i>
</button>
<a href="<?php echo base_url('users/view_edit_form/'.$row->user_id); ?>" class="btn btn-success">
<i class="fas fa-user-edit"></i>
</a>
<a href="" class="btn btn-danger">
<i class="fas fa-ban"></i>
</a>
</td>
<?php endforeach; ?>
My Modal
<div class="modal fade" id="info_modal<?php echo $row->user_id; ?> " tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel"><?php echo $row->firstname; ?></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
I expect the output will display more information of the user but the actual output is an error message Message: Trying to get property 'user_id' of non-object
try to check what $row contains.
If -> don't work, try using $row['user_id']
Basically I have this code where I want to extract some data from a database and display it on a pop-up window. The problem is when I click on the eye icon ( labelled More ) I want it to display the correspondent id of that table row but I can't seem to figure out how to do that.
For more references I set up a temporary website to better see the problem : http://twgtest-org.stackstaging.com/bau50/bau50_extract.php
You can see that when I click on more the displayed ID is actually all the IDs from the database instead of it being only the ID of that row
<?php
//load database connection
$pdo = new PDO("mysql:host=$host;dbname=$database_name", $user, $password, array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
));
$query_string = "SELECT * FROM bau50";
$query = $pdo->prepare($query_string);
$query->execute();
?>
<body>
<div class="container">
<ul class="text-align">
<?php
if (!$query->rowCount() == 0) {
while ($show_all = $query->fetch()) {
echo '<tr><th scope="row">';
echo $show_all['id_Bau50'];
echo '</th><td>';
echo $show_all['name'];
echo '</td><td>';
echo $show_all['produkt'];
echo '</td><td>';
echo $show_all['preis']," €";
echo '</th><td>';
echo $show_all['Ergebniss'];
echo '</td>
<td><p data-placement="top" data-toggle="tooltip" title="more"><button class="btn btn-primary btn-xs" data-title="more" data-toggle="modal" data-target="#more" ><span class="fa fa-eye"></span></button></p></td>
<td><p data-placement="top" data-toggle="tooltip" title="Edit"><button class="btn btn-secondary btn-xs" data-title="Edit" data-toggle="modal" data-target="#edit" ><span class="fa fa-pencil"></span></button></p></td>
<td><p data-placement="top" data-toggle="tooltip" title="Delete"><button class="btn btn-danger btn-xs" data-title="Delete" data-toggle="modal" data-target="#delete" ><span class="fa fa-trash"></span></button></p></td></tr>';
}
echo '</tbody></table>';
}
?></ul>
</div>
<?php
$query_view = "SELECT * FROM bau50";
$query2= $pdo->prepare($query_view);
$query2->execute();
echo'<div class="modal fade" id="more" tabindex="-1" role="dialog" aria-labelledby="more" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><span class="fa fa-remove" aria-hidden="true"></span></button>
<h4 class="modal-title custom_align" id="Heading">More</h4>
</div>
<div class="modal-body">
<div>';
while ($show= $query2->fetch()) {
$id= $show ['id_Bau50'];
echo $id;
}
echo '</div>
<div class="modal-footer ">
<button type="button" class="btn btn-secondary btn-lg" style="width: 100%;" data-toggle="modal" data-target="#edit"><span class="fa fa-pencil"></span> Update</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
</div>';
?>
This is the very simply solution: add a new modal for each row identified by its id for example for id "4" you will open the modal with id "modal4" and so on:
<?php
//load database connection
$pdo = new PDO("mysql:host=$host;dbname=$database_name", $user, $password, array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
));
$query_string = "SELECT * FROM bau50";
$query = $pdo->prepare($query_string);
$query->execute();
?>
<body>
<div class="container">
<ul class="text-align">
<?php
if (!$query->rowCount() == 0) {
while ($show_all = $query->fetch()) {
echo '<tr><th scope="row">';
echo $show_all['id_Bau50'];
echo '</th><td>';
echo $show_all['name'];
echo '</td><td>';
echo $show_all['produkt'];
echo '</td><td>';
echo $show_all['preis']," €";
echo '</th><td>';
echo $show_all['Ergebniss'];
echo '</td>
<td><p data-placement="top" data-toggle="tooltip" title="more"><button class="btn btn-primary btn-xs" data-title="more" data-toggle="modal" data-target="#more'.$show_all['id_Bau50'].'" ><span class="fa fa-eye"></span></button></p></td>
<td><p data-placement="top" data-toggle="tooltip" title="Edit"><button class="btn btn-secondary btn-xs" data-title="Edit" data-toggle="modal" data-target="#edit" ><span class="fa fa-pencil"></span></button></p></td>
<td><p data-placement="top" data-toggle="tooltip" title="Delete"><button class="btn btn-danger btn-xs" data-title="Delete" data-toggle="modal" data-target="#delete" ><span class="fa fa-trash"></span></button></p></td></tr>';
}
echo '</tbody></table>';
}
?></ul>
</div>
<?php
$query_view = "SELECT * FROM bau50";
$query2= $pdo->prepare($query_view);
$query2->execute();
while ($show= $query2->fetch()) {
$id= $show ['id_Bau50'];
echo'<div class="modal fade" id="more'.$id.'" tabindex="-1" role="dialog" aria-labelledby="more" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><span class="fa fa-remove" aria-hidden="true"></span></button>
<h4 class="modal-title custom_align" id="Heading">More</h4>
</div>
<div class="modal-body">
<div>';
echo $id;
echo '</div>
<div class="modal-footer ">
<button type="button" class="btn btn-secondary btn-lg" style="width: 100%;" data-toggle="modal" data-target="#edit"><span class="fa fa-pencil"></span> Update</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
</div>';
}
?>
This is ok for not so many rows or if you don't want to write some javascript.
A nicer solution would be to use one single modal with all content inside and show/hide the selected one, for this you need to use some js code and don't use the standard bootstrap attribute-driven methods.
In this example I'm using jquery and js code (se at the bottom).
<?php
//load database connection
$pdo = new PDO("mysql:host=$host;dbname=$database_name", $user, $password, array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
));
$query_string = "SELECT * FROM bau50";
$query = $pdo->prepare($query_string);
$query->execute();
?>
<body>
<div class="container">
<ul class="text-align">
<?php
if (!$query->rowCount() == 0) {
while ($show_all = $query->fetch()) {
echo '<tr><th scope="row">';
echo $show_all['id_Bau50'];
echo '</th><td>';
echo $show_all['name'];
echo '</td><td>';
echo $show_all['produkt'];
echo '</td><td>';
echo $show_all['preis']," €";
echo '</th><td>';
echo $show_all['Ergebniss'];
echo '</td>
<td><p data-placement="top" data-toggle="tooltip" title="more"><button class="btn btn-primary btn-xs" data-moreid="'.$show_all['id_Bau50'].'" ><span class="fa fa-eye"></span></button></p></td>
<td><p data-placement="top" data-toggle="tooltip" title="Edit"><button class="btn btn-secondary btn-xs" data-title="Edit" data-toggle="modal" data-target="#edit" ><span class="fa fa-pencil"></span></button></p></td>
<td><p data-placement="top" data-toggle="tooltip" title="Delete"><button class="btn btn-danger btn-xs" data-title="Delete" data-toggle="modal" data-target="#delete" ><span class="fa fa-trash"></span></button></p></td></tr>';
}
echo '</tbody></table>';
}
?></ul>
</div>
<div class="modal fade" id="more" tabindex="-1" role="dialog" aria-labelledby="more" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><span class="fa fa-remove" aria-hidden="true"></span></button>
<h4 class="modal-title custom_align" id="Heading">More</h4>
</div>
<div class="modal-body">
<?php
$query_view = "SELECT * FROM bau50";
$query2= $pdo->prepare($query_view);
$query2->execute();
while ($show= $query2->fetch()) {
$id= $show ['id_Bau50'];
echo '<div id="more'.$id.'">'.$id.'</div>';
}
?>
</div>
<div class="modal-footer ">
<button type="button" class="btn btn-secondary btn-lg" style="width: 100%;" data-toggle="modal" data-target="#edit"><span class="fa fa-pencil"></span> Update</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- YOU NEED JQUERY FOR THIS: -->
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script type="text/javascript">
$(function(){
$("button[data-moreid]").click(function(){
$("#more .modal-body > div").hide(); //hide all more div
var id=$(this).attr("data-moreid"); //get id from pushed button
$("#more .modal-body #more"+id).show(); //show only pushed id
$("#more").modal("show"); //show modal
});
});
</script>
i have a bootstrap modal and am trying to pass a unique value through GET to the modal but the modal keeps getting the same unique value instead of the value of the table row i clicked. Been struggling with this for days and cant seem to figure out why it's not working. The code is below
<?php
$sql = "SELECT * FROM houses";
$q=$conn->query($sql);
while ($row = mysqli_fetch_array($q)) {
?>
<tr>
<td><?php echo $row['nickname']; ?></td>
<td><?php echo $row['state']; ?></td>
<td><?php echo $row['city']; ?></td>
<td><?php echo $row['address']; ?></td>
<td>
<div class="btn-group">
<a class="btn btn-success" href="view_property.php?house=<?php echo $row['nickname']; ?>"><i class="icon_check_alt2"></i></a>
<a class="btn btn-primary" href="edit_property.php?house=<?php echo $row['nickname']; ?>"><i class="icon_plus_alt2"></i></a>
<a class="btn btn-danger" data-toggle="modal" data-target="#myDelete"><i class="icon_close_alt2"></i></a>
</div>
<div id="myDelete" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Delete Property</h4>
</div>
<div class="modal-body">
<p>Are you sure you want to pull out this property from your list of Properties, as all data regarding this property will be lost permanently <?php echo $row['nickname']; ?></p>
</div>
<div class="modal-footer">
<a class="btn btn-success" href="view_property.php?house=<?php echo $row['nickname']; ?>">Delete</a>
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
</td>
HTML ids should be unique, you're using the same id for every iteration.
Try using:
id="myDelete<?php echo $row['id'] ?>"
data-target="#myDelete<?php echo $row['id'] ?>"
Hope this helps!
I am trying to display hilios countdown jquery plugin for each member but same countdown is displaying for all member. image is showing that the countdown for all memebers is same. pLease help .i am echoeing expiry for all members from database of column with name "expiry" and "expiry" is not echoing hilios countdown for all members
<?php
$sql = "SELECT d.*, c.* from details as d, customer as c where d.customerId = c.id AND c.cmpId = '$idCompany'";
/*$sql = "SELECT * from customer where cmpId = '$idCompany' ";*/
$result = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
?>
<tbody>
<tr>
<td>
<?php echo $row['id'] ?>
</td>
<td>
<?php echo '<img src="images/'.$row['image'].'"; width="100px"; hieght="100px">' ?>
<?php echo $row['fname']." ".$row['lname']?>
<span class="user-subhead">Member</span>
</td>
<td>
<?php echo $row['time'] ?>
</td>
<td class="text-center countdown">
<!-- Countdown (please check this countdown where the expiry for each member has to echo but same expiry is echoing for all members)-->
<span class="label label-default getting-started"></span>
<script type="text/javascript">
$(".getting-started").each(function(){
$('.getting-started').countdown('<?php echo $row["expiry"] ?> ' , function(time) {
$(this).html(time.strftime('%w wk %d d %H h %M m %S s'));
});
})
//})
</script>
</td>
<td>
<?php echo $row['mobile'] ?>
</td>
<td style="width: 20%;">
<a style="float:left" data-toggle="modal" data-target="#memberInfo" href="<?php echo $row['id']; ?>" class="table-link clsMemberInfo view">
<span class="fa-stack">
<i class="fa fa-square fa-stack-2x"></i>
<i class="fa fa-search-plus fa-stack-1x fa-inverse"></i>
</span>
</a>
<a style="float:left" href="#" class="table-link" id="#save">
<span class="fa-stack">
<i class="fa fa-square fa-stack-2x"></i>
<i class="fa fa-pencil fa-stack-1x fa-inverse"></i>
</span>
</a>
<a href="<?php echo $row['id'] ?>" class="table-link danger delmodal" data-toggle="modal" data-target="#deleteModal">
<span class="fa-stack">
<i class="fa fa-square fa-stack-2x"></i>
<i class="fa fa-trash-o fa-stack-1x fa-inverse"></i>
</span>
</a>
</td>
</tr>
</tbody>
<div class="modal fade" id="deleteModal" class="" role="dialog">
<div class="modal-dialog modal-md">
<div class="modal-content">
<div class="modal-body text-center">
<p>Are you Sure you want to Delete ?</p>
</div>
<div class="modal-footer">
<div class="col-lg-7">
<form method="post" id="deleteForm">
<input type="hidden" id="MemberId" name="MemberId" value="<?php echo $row['id']?>">
<button type="submit" name="submit" id="yes_btn" class="btn btn-danger yes_btn">Yes</button>
</form>
<button type="button" id="no_btn" class="btn btn-success" data-dismiss="modal">No</button>
</div>
</div>
</div>
</div>
</div>
<?php
}
?>
Giving the following manual:
enter link description here
It is quite easy to have a child view and echo it when I know captureTo used in the controller (e.g. "<?php echo $this->article ?>"), but can I do similar when I generate view models dynamically, and assign them to dynamically generated captureTo for addChild() function:
foreach ($studentEvaluations as $studEval) {
$studEvalId = $studEval->getEvalId();
$formViewModel = $this->buildStudentEvaluationViewModel($studEval);
$viewModel->addChild($formViewModel, $studEvalId);
}
I tried the following, but it does not work:
<?php foreach ($this->viewModel()->getCurrent()->getIterator() as $studId => $studEval) : ?>
<tr>
<td><?php echo $this->escapeHtml($studEval->fname); ?></td>
<td><?php echo $this->escapeHtml($studEval->lname); ?></td>
<td><?php echo $this->escapeHtml($studEval->formName); ?></td>
<td><?php echo $this->escapeHtml($studEval->supdated); ?></td>
<td><?php echo $this->escapeHtml($studEval->screated); ?></td>
<td>
<button class="btn btn-primary btn-lg"
data-toggle="modal"
data-target="#myModal<?php echo $studId; ?>"
data-loading-text="Loading..."> Edit
</button>
<!-- Modal -->
<div class="modal fade" id="myModal<?php echo $studId; ?>" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
<p>
<!-- HERE ->>>>>>>>> --> <?php echo $studEval ?>
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
</td>
</tr>
<?php endforeach; ?>
EDIT 1
This is an error when I try to output the view in the this way:
Catchable fatal error: Object of class Zend\View\Model\ViewModel could not be converted to string in C:\dev\projects\OnlineFieldEvaluation\module\OnlineFieldEvaluation\view\online-field-evaluation\online-field-evaluation\test3.phtml on line 62
I found how to do it. It was just my luck of knowledge in PHP:
<?php foreach ($this->viewModel()->getCurrent()->getChildren() as $studEval) : ?>
<tr>
<td><?php echo $this->escapeHtml($studEval->fname); ?></td>
<td><?php echo $this->escapeHtml($studEval->lname); ?></td>
<td><?php echo $this->escapeHtml($studEval->formName); ?></td>
<td><?php echo $this->escapeHtml($studEval->supdated); ?></td>
<td><?php echo $this->escapeHtml($studEval->screated); ?></td>
<td>
<button class="btn btn-primary btn-lg"
data-toggle="modal"
data-target="#myModal<?php echo $studEval->captureTo(); ?>"
data-loading-text="Loading...">
Edit <?php echo $studEval->captureTo(); ?>
</button>
<!-- Modal -->
<div class="modal hide fade" id="myModal<?php echo $studEval->captureTo(); ?>" tabindex="-1"
role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
<p>
<?php
echo $this->{$studEval->captureTo()};
?>
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
</td>
</tr>
<?php endforeach; ?>