AJAX에서 작동하는 CSFR 보호를위한 CakePHP 보안 구성 요소를 얻으려고합니다.
addedit()
보기가 포함 된 내 ArtistsDates
- 컨트롤러 (아티스트/DJ가 보유한 모든 일정을 저장하는 데 사용)가 있습니다.cakePHP 2.2 : Ajax가로드 된 CFSR 보안 구성 요소 및 뷰
이보기는 jQuery AJAX를 통해 jQuery Modalbox에로드됩니다. (SimpleModal)
function artist_dates(request){
.
.
if(request == 'load'){
$.ajax({
type: 'post',
url: $('base').attr('href') + '/artist_dates/addedit/'+artist_id,
success: function(html){
$('#dialog').html(html);
$('#dialog').modal({
modal: false,
maxHeight:'500px',
minHeight:500,
minWidth:750,
});
}
});
}
.
.
}
이보기에, 내 양식 addedit_daterow_form
로 렌더링됩니다 - 요소. 이 요소는 데이터 또는 "NEW"-Mode에서 호출됩니다. 데이터가 제공되면 요소는 데이터를 표시하고 숨겨진 편집 양식을 포함합니다. "NEW"-Mode에서 호출되면 빈 폼을 반환합니다. 그래서,이 요소는 모든 ArtistDate
에서 DataRow를위한 렌더링 - 모델
을 (여기 뷰의 스크린 샷입니다 : http://i.stack.imgur.com/Ye10v.png) (새로운 하나를 추가하기위한 더 일!) -Component가 포함되어
Security
가 ArtistDatesController
. 불행히도 $this->Form->request->params
에는 보기 또는 addedit_daterow_form
요소에 [_Token]
이 포함되어 있지 않습니다. 내 jQuery-AJAX-Function에서 뭔가를 변경해야합니까?
- 편집 1 : 사전에
<?php echo $this->Form->create('ArtistDate', array('controller' => 'artist_dates','action' => 'addedit', 'id' => 'artistDateForm_'.$date_nr)); ?>
<?php echo pr($this->Form->request->params); ?>
<?php echo $this->Form->input('ArtistDate.'.$date_nr.'.id',array('type' => 'hidden', 'value' => $date['ArtistDate']['id'])); ?>
<?php echo $this->Form->input('ArtistDate.'.$date_nr.'.artist_id',array('type' => 'hidden', 'value' => $date['ArtistDate']['artist_id'])); ?>
<div class="date">
<?php echo $this->Form->input('ArtistDate.'.$date_nr.'.date', array('type' => 'text','label' => 'Date <span style="font-weight:normal; float:right;">[DD.MM.YYYY]</span>','value' => (!empty($date['ArtistDate']['date']) ? date('d.m.Y',strtotime($date['ArtistDate']['date'])) : ''))); ?>
<?php echo $this->Form->input('ArtistDate.'.$date_nr.'.date_end', array('type' => 'text','label' => 'Enddate <span style="font-weight:normal; float:right;">[DD.MM.YYYY]</span>','value' =>(!empty($date['ArtistDate']['date_end']) ? date('d.m.Y',strtotime($date['ArtistDate']['date_end'])) : ''))); ?>
</div>
<div class="venue">
<?php echo $this->Form->input('ArtistDate.'.$date_nr.'.venue', array('type' => 'text','value' => $date['ArtistDate']['venue'])); ?>
<?php echo $this->Form->input('ArtistDate.'.$date_nr.'.city', array('type' => 'text','value' => $date['ArtistDate']['city'])); ?>
</div>
<div class="link">
<?php echo $this->Form->input('ArtistDate.'.$date_nr.'.venuelink', array('type' => 'text','label' => 'Link <span style="font-weight:normal; float:right;">Venue</span>','value' => $date['ArtistDate']['venuelink'])); ?>
<?php echo $this->Form->input('ArtistDate.'.$date_nr.'.ticketslink', array('type' => 'text','label' => 'Link <span style="font-weight:normal; float:right;">Tickets</span>','value' => $date['ArtistDate']['ticketslink'])); ?>
</div>
<div class="actions">
<?php echo $this->Html->link('','',array('class' => 'buttonsave','onclick' => "artistdate_handling('".$date_nr."','save'); return false;", 'style' => $display_exists, 'escape' => false, 'title' => 'Save')); ?>
<?php echo $this->Html->link('','',array('class' => $approveclass, 'onclick' => "artistdate_handling('".$date_nr."','confirm'); return false;", 'style' => $display_exists, 'escape' => false, 'title' => 'Confirm Show')); ?>
<?php echo $this->Html->link('','',array('class' => 'buttondelete','onclick' => "artistdate_handling('".$date_nr."','delete'); return false;", 'style' => $display_exists, 'escape' => false, 'title' => 'Delete Show')); ?>
<?php echo $this->Html->link('','',array('class' => 'buttonadd','onclick' => "artistdate_handling('".$date_nr."','add'); return false;", 'style' => $display_new, 'escape' => false, 'title' => 'Add Show')); ?>
</div>
<div style="clear:both"></div>
<?php echo $this->Form->end(); ?>
덕분에 많은 :이 내 폼 코드처럼 보이는 방법입니다!