Well the problem is as follows, create a field in the database
@KacosPro
and connect a page to make an ibdate in this.
The thing is that now I must connect it from another page that shows a table, the thing is that it does not do anything to me and I think it's because of the model
This is the model format that I have always handled:
<?php
App::uses('AppModel', 'Model');
class Need extends AppModel {
public $validate = array(
'client' => array(
'rule' => 'notBlank'
),
'date' => array(
'rule' => 'notBlank'
),
'id' => array(
'rule' => 'notBlank'
),
'need' => array(
'rule' => 'notBlank'
),
'objective' => array(
'rule' => 'notBlank'
),
'process' => array(
'rule' => 'notBlank'
)
);
}
As you can see there, I mention all the fields that the database has, which are client, date, id, need, objective and process.
Now on the page that I'm working on has the following model:
class Doctor extends AppModel {
public $belongsTo = array('Doctitle');
public $hasAndBelongsToMany = array(
'Education' =>
array(
'className' => 'Specialty',
'joinTable' => 'doctor_education',
'foreignKey' => 'doctor_id',
'associationForeignKey' => 'specialty_id',
'unique' => true,
),
);
public $validate = array(
'name' => array(
'rule' => 'notBlank'
),
'acepto' => array(
'rule' => 'notBlank'
),
'image' => array(
'rule' => array(
'isValidMimeType',
array('image/jpeg', 'image/png', 'image/gif'),
false
),
'allowEmpty' => true,
'message' => 'File is not an image',
),
);
/* using the upload plugin */
public $actsAs = array(
'Upload.Upload' => array(
'image' => array(
'path' => '{ROOT}webroot{DS}img{DS}uploads{DS}',
'thumbnailSizes' => array(
'thumb' => '150w'
),
// uncoment next if "imagick not found"
'thumbnailMethod' => 'php',
),
)
);
}
I added 'acepto' => array(
'rule' => 'notBlank'
),
thinking that with that I would connect with the field that believes in the database, but it was not like that.
This is the driver:
public function admin_index()
{
//select the layout for the admin
$this->layout = 'admin';
$this->response->disableCache();
$this->Doctor->recursive = 0;
$DoctorList = $this->Doctor->find('list', array('order' => 'name ASC'));
$Doctors = $this->Doctor->find('all', array('order' => 'name ASC'));
$this->set(compact('DoctorList', 'Doctors'));
}
Or I suppose that is the ps driver according to the following button there is where you access:
<?php
$active = false;
if($active_menu == 'Cirujanos') $active = 'active';
echo $this->Html->link('<i class="fa fa-user-md fa-fw"></i> <span>Cirujanos</span>',
array('controller' => 'doctors', 'action' => 'index', 'admin' => true),
array('escape' => false, 'class' => $active)
);
?>
Good and here are the fields of the BD
I need to access acepto
and well the view is loaded like this:
<table class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th>#</th>
<th>Foto</th>
<th>Trato</th>
<th>Nombre</th>
<th>Resumen</th>
<th>Aprobo</th>
</tr>
</thead>
<tbody>
<?php
$count = 1;
foreach ($Doctors as $doctor) {
echo "<tr data-doctor_id='".$doctor['Doctor']['id']."' class='activeRow' >";
echo "<td>".$count."</td>";
if($doctor['Doctor']['image']){
echo "<td>";
echo $this->Html->image('uploads/'.$doctor['Doctor']['id']."/thumb_".$doctor['Doctor']['image'],
array('alt' => $doctor['Doctor']['name']));
echo "</td>";
}else{
echo "<td></td>";
}
echo "<td class='bordered'>".$doctor['Doctitle']['title']."</td>";
echo "<td class='bordered'>".$doctor['Doctor']['name']."</td>";
echo "<td class='bordered'>".substr($doctor['Doctor']['description'], 0, 60)."</td>";
echo "<td class='bordered'>".$doctor['Doctor']['acepto']."</td>";
echo "</tr>";
$count++;
}
?>
</tbody>
</table>
In this table, load all the fields except the new one that I add echo "<td class='bordered'>".$doctor['Doctor']['acepto']."</td>";
, the acepto
and the others if you load them.