x-editable bootstrap-4 table - validate input not working nor is POST values

377 Views Asked by At

I have a bootstrap 4 table with x-editable. When I edit the table I want to ensure the user cannot have an empty field. Seems pretty straightforward, but I can't seem to make it work. Here is my index.php:

......
<tr>
<th data-name="deviceId" data-field="deviceId" data-sortable="true">ID</th>
 <th data-name="hostname" data-field="hostname_id" data-align="center" data-sortable="true" data-editable="true">Hostname</th>


</tr>
......
<?php
  while($row = $result->fetch_assoc()) {  ?>
    <tr>
        <td><?php echo $row["deviceId"]; ?></a></td>
       <td data-name="hostname" data-pk="<?php echo $row["deviceId"]; ?>" class="editable editable-click editField" data-abc="true"><?php echo $row["hostname_id"]; ?></td>
       <td data-name="ip" data-pk="<?php echo $row["deviceId"]; ?>" class="editable editable-click editField" data-abc="true"><?php echo $row["ip"]; ?></td>

And my index.js:

  $('.editable').editable({
        type: 'text',
        url:'update.php',
        title:'Hostname',
        type:'POST',
        validate:function(value){
            if($.trim(value) == '')
            {
                console.log("empty");
                return 'This field is required';
            }
        }
    });

And finally my update.php:

$pk = $_POST['pk'];
$name = $_POST['name'];
$value = $_POST['value'];
error_log("values are " . $pk . ', ' . $name . ", " . $value);

I do not see a response in the console, and I can put anything (including nothing) in the input field. I also see nothing passed to my update function. Can someone tell me what I am doing wrong?

0

There are 0 best solutions below