Yani bir formu oluşturucu oluşturma. Kullanıcılar, giriş ve ardından Yöneticiler oluşturduğunuz formları fillout olacaktır. Ben "" yöntemi eklemek my "data_controller" in () SaveAll kullanıyorum.
Bu iyi çalışır ve ve bu gibi görünüyor:
//debug($this->data); prints the following
//app/controllers/data_controller.php (line 21)
Array
(
[Datum] => Array
(
[0] => Array
(
[bool_val] => 1
[field_id] => 56
[form_id] => 208
[user_id] => 1
)
[1] => Array
(
[bool_val] => 0
[field_id] => 64
[form_id] => 208
[user_id] => 1
)
)
)
// data_controller.php
// the add method is like this
function add() {
debug($this->data);
if (!empty($this->data) ) {
$this->Datum->create();
if ($this->Datum->saveAll($this->data['Datum'])) {
$this->Session->setFlash(__('The Datum has been saved', true));
$this->redirect(array('action'=>'index'));
} else {
$this->Session->setFlash(__('The Datum could not be saved. Please, try again.', true));
}
}
$forms = $this->Datum->Form->find('list');
$fields = $this->Datum->Field->find('list');
$users = $this->Datum->User->find('list');
$statuses = $this->Datum->Status->find('list');
$this->set(compact('forms', 'fields', 'users', 'statuses'));
}
Böylece çalışıyor ve benim MySQL veritabanı "veri" tablosunda yeni girişler bir dizi oluşturur. Ben kullanmaya çalışırken hata geliyor "SaveAll ()" my "düzenlemek" yöntemi. Ben googled google'dan ve hayır şans googled var. Tüm makaleler benim veri yapısı doğru olması gerektiğini söylüyorlar, ya da ben onları anlama ediyorum nasıl olduğunu.
Yani burada benim görünümüdür. Bu çıkış onay kutularını ve diğer form elemanları aracılığıyla döngüsü ama biz sadece basit bir onay kutusunu tek örnek bakacağız.
//field_view_datum.ctp
<?php
//debug($field_datum);
switch ($field['Type']['name']) {
case "check box" :
echo "<p>";
echo $form->label($field['FieldName'][0]['name']);
echo $form->hidden('Datum.'.$field_datum['id'].'.id', array('value' => $field_datum['id']));
echo $form->hidden('Datum.'.$field_datum['id'].'.form_id', array('value' => $formID));
echo $form->hidden('Datum.'.$field_datum['id'].'.field_id', array('value' => $field['id']));
echo $form->hidden('Datum.'.$field_datum['id'].'.user_id', array('value' => $userID));
$booly = ($field_datum['bool_val'] == 0) ? false : true;
$options = array('checked' => $booly);
echo $form->checkbox('Datum.'.$field_datum['id'].'.bool_val', $options);
echo "</p>";
break;
Benim görüşüm irade çıktı tarayıcıya aşağıdaki HTML.
<p>
<label for="DatumFieldOne">Field One</label>
<input type="hidden" id="Datum164Id" value="164" name="data[Datum][164][id]"/>
<input type="hidden" id="Datum164FormId" value="208" name="data[Datum][164][form_id]"/>
<input type="hidden" id="Datum164FieldId" value="56" name="data[Datum][164][field_id]"/>
<input type="hidden" id="Datum164UserId" value="1" name="data[Datum][164][user_id]"/>
<input type="hidden" value="0" id="Datum164BoolVal_" name="data[Datum][164][bool_val]"/>
<input type="checkbox" id="Datum164BoolVal" value="1" checked="checked" name="data[Datum][164][bool_val]"/>
</p>
<p>
<label for="DatumFieldTwo">Field Two</label>
<input type="hidden" id="Datum165Id" value="165" name="data[Datum][165][id]"/>
<input type="hidden" id="Datum165FormId" value="208" name="data[Datum][165][form_id]"/>
<input type="hidden" id="Datum165FieldId" value="64" name="data[Datum][165][field_id]"/>
<input type="hidden" id="Datum165UserId" value="1" name="data[Datum][165][user_id]"/>
<input type="hidden" value="0" id="Datum165BoolVal_" name="data[Datum][165][bool_val]"/>
<input type="checkbox" id="Datum165BoolVal" value="1" name="data[Datum][165][bool_val]"/>
</p>
Ben formu gönderdiğinizde Öyleyse ben aşağıdaki hatayı alıyorum:
Fatal error: Call to a member function getColumnType() on a non-object in /cake/libs/model/model.php on line 949
Ben geçirerek veri ve benim denetleyicisi yöntemi aşağıdaki gibi görünür:
//debug($this->data['Datum']); prints the following
app/controllers/data_controller.php (line 39)
Array
(
[164] => Array
(
[id] => 164
[form_id] => 208
[field_id] => 56
[user_id] => 1
[bool_val] => 1
)
[165] => Array
(
[id] => 165
[form_id] => 208
[field_id] => 64
[user_id] => 1
[bool_val] => 1
)
)
//data_controller.php
function edit($formid = null) {
debug($this->data['Datum']);
if (!empty($this->data) ) {
if ($this->Datum->saveAll($this->data['Datum'])) {
$this->Session->setFlash(__('The Datum has been saved', true));
$this->redirect(array('controller' => 'forms', 'action'=>'index'));
} else {
$this->Session->setFlash(__('The Datum could not be saved. Please, try again.', true));
$this->redirect(array('controller' => 'forms', 'action'=>'view', 'id' => '$formid'));
}
}
}
Any help that you can give would be much appreciated I have done tons of searching and not found the correct answer. Sorry if this post is a bit long winded. Thanks, Devin
[EDIT]
Eğer benim bir model ya da benim tablo yapısına bakmak gerekir.
//Model
//datum.php
// a basic model nothing unusual here
<?php
class Datum extends AppModel {
var $name = 'Datum';
var $belongsTo = array(
'Form' => array(
'className' => 'Form',
'foreignKey' => 'form_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Field' => array(
'className' => 'Field',
'foreignKey' => 'field_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'User' => array(
'className' => 'User',
'foreignKey' => 'user_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Status' => array(
'className' => 'Status',
'foreignKey' => 'status_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
}
?>
//this is from my latest schema snapshot
var $data = array(
'id' => array('type' => 'integer', 'null' => false, 'default' =>
NULL, 'key' => 'primary'),
'form_id' => array('type' => 'integer', 'null' => true, 'default'
=> NULL),
'field_id' => array('type' => 'integer', 'null' => true, 'default'
=> NULL),
'user_id' => array('type' => 'integer', 'null' => true, 'default'
=> NULL),
'status_id' => array('type' => 'integer', 'null' => true,
'default' => NULL),
'value' => array('type' => 'text', 'null' => true, 'default' =>
NULL),
'file_path' => array('type' => 'string', 'null' => true, 'default'
=> NULL),
'bool_val' => array('type' => 'boolean', 'null' => true, 'default'
=> '0'), // I am using MySQL so this is a tinyint(1)
'created' => array('type' => 'datetime', 'null' => true, 'default'
=> NULL),
'modified' => array('type' => 'datetime', 'null' => true,
'default' => NULL),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique'
=> 1))
);
[EDIT]
Yani bir poster olarak önerilen yaptım ve bu koyarken ne var "ayıklama ($ modeli);" cake / libs / model / model.php (line 949) hakkında:
cake/libs/model/model.php (line 949)
data //this being what debug() returns
Fatal error: Call to a member function getColumnType() on a non-object in /cake/libs/model/model.php on line 950
Benim model adı Veri ya da benim kafamda belirgin çözüm var datum.php değil veridir yanlış olduğunu görebilirsiniz, bu benim için Kek biraz derin. Herhangi Öneriler?
Ben sadece aynı hata ayıklama deyimi ile benim "view" yöntemiyle bir göz attım ve "Datum'u" ve "veri" Ben "edit" yöntemiyle almak gibi çıktılar. Sadece herkes için yararlı olduğu durumda.