@Dmitriy-Kim

Как переменная frequency записывается в БД?

Добрый день!
Помогите понять как переменная "frequency" попадет в БД. Сайт написан на CakePHP

Вот шаблон редактирования:
<div class="content-up">
	<span class="content-up__heading">Редактирование материала</span>
</div>
<div class="add-part">
	<?php 
		echo $this->Form->create('Imap', array('type' => 'file'));
	?>
	<div class="edit_bot">

		<div class="bot_r">
		<?php
		echo $this->Form->input('region_id', array('label' => 'Область:', 'class' => 'region_list'));?>
<select id="districts" name="data[Imap][district_id]">
		<option value="0">Выберите район</option>
	<?php foreach($districts as $key => $value): ?>
		<option value="<?=$key?>" <?=($key == $data['Imap']['district_id']) ? 'selected' : ''?>><?=$value?></option>
	<?php endforeach ?>
</select>
<select class="towns" name="data[Imap][town_id]">
<option value="0">Выберите населенный пункт</option>
	<?php foreach($towns as $key => $value): ?>
		<option value="<?=$key?>" <?=($key == $data['Imap']['town_id']) ? 'selected' : ''?>><?=$value?></option>
	<?php endforeach ?>
</select>
<?php
echo $this->Form->input('title', array('label' => 'Наименование:'));
echo $this->Form->input('dates', array('label' => 'Дата ввода:'));
echo $this->Form->input('frequency', array('label' => 'Частота сигнала:'));
echo $this->Form->input('latitude', array('label' => 'Широта:'));
echo $this->Form->input('longitude', array('label' => 'Долгота:'));
echo $this->Form->input('diameter', array('label' => 'Диаметр:'));
		echo $this->Form->end('Редактировать');
		?>
		</div>
	</div>
	<script type="text/javascript">
		 //CKEDITOR.replace( 'editor' );
	</script>
</div>


А вот контролер который отвечает за этот шаблон
<?php

class ImapsController extends AppController{
	public function beforeFilter(){
		parent::beforeFilter();
	}
	// public $uses = array('Imap', 'Region');


	public function admin_index(){
		$data = $this->Imap->find('all');
		$this->set(compact('data'));
	}

	public function admin_add(){
		if($this->request->is('post')){
			$this->Imap->create();
			$data = $this->request->data['Imap'];
			if($this->Imap->save($data)){
				$this->Session->setFlash('Сохранено', 'default', array(), 'good');
				return $this->redirect($this->referer());
			}else{
				$this->Session->setFlash('Ошибка', 'default', array(), 'bad');
			}
		}
		$this->Imap->Region->locale = 'ru';
		$regions = $this->Imap->Region->find('list');
		$this->set(compact('title_for_layout', 'regions'));
	}

	public function admin_edit($id){

		if(is_null($id) || !(int)$id || !$this->Imap->exists($id)){
			throw new NotFoundException('Такой страницы нет...');
		}

		$data = $this->Imap->findById($id);

		if(!$id){
			throw new NotFoundException('Такой страницы нет...');
		}
		if($this->request->is(array('post', 'put'))){
			$this->Imap->id = $id;
			$data1 = $this->request->data['Imap'];
			$data1['id'] = $id;
			if($this->Imap->save($data1)){
				$this->Session->setFlash('Сохранено', 'default', array(), 'good');
				return $this->redirect($this->referer());
			}else{
				$this->Session->setFlash('Ошибка', 'default', array(), 'bad');
			}
		}
		//Заполняем данные в форме
		if($this->request->is('post')){
			$this->request->data = $data1;
			$data = $data1;
		}else{
			$data = $this->request->data = $this->Imap->read(null, $id);
		}
		$this->Imap->Region->locale = 'ru';
		$this->Imap->District->locale = 'ru';
		$this->Imap->Town->locale = 'ru';
		$regions = $this->Imap->Region->find('list');
		$districts = $this->Imap->District->find('list');
		$towns = $this->Imap->Town->find('list');
		$this->set(compact('id', 'data', 'regions','districts', 'dates', 'towns'));
	}

	public function admin_delete($id){
		if (!$this->Imap->exists($id)) {
			throw new NotFounddException('Такой статьи нет');
		}
		if($this->Imap->delete($id)){
			$this->Session->setFlash('Удалено', 'default', array(), 'good');
		}else{
			$this->Session->setFlash('Ошибка', 'default', array(), 'bad');
		}
		return $this->redirect($this->referer());
	}

}


В модели тоже данной переменной нет, но при редакции в БД ее значение записывается. Не подскажите куда копать?
  • Вопрос задан
  • 45 просмотров
Пригласить эксперта
Ответы на вопрос 1
GeraJet
@GeraJet
Anykey
$this->Form->create('Imap', array('type' => 'file'));
//...
$data = $this->request->data['Imap'];
соответственно в $data будут данные из всех полей формы
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы