Last active
December 22, 2015 23:08
-
-
Save chrisvogt/6544371 to your computer and use it in GitHub Desktop.
HABTM POST data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Events Controller: assign() method | |
*/ | |
public function assign() { | |
if ($this->request->is('post')) { | |
if ($this->Event->saveAll($this->request->data)) { | |
$this->Session->setFlash(__('The attendee list has been updated.'), 'flash/success'); | |
$this->redirect(array('action' => 'index')); | |
} else { | |
$this->Session->setFlash(__('The event could not be saved. Please, try again.'), 'flash/error'); | |
} | |
} | |
$events = $this->Event->find('list'); | |
$this->loadModel('Attendee'); | |
$attendees = $this->Attendee->find('list'); | |
$this->set(compact('events', 'attendees')); | |
} | |
## ------------------------- | |
/** | |
* Events View: Assign Method View | |
*/ | |
<div id="page-container" class="row-fluid"> | |
<div id="page-content" class="span6 offset3"> | |
<div class="well"> | |
<div class="assignment form"> | |
<?php echo $this->Form->create('Event', array('inputDefaults' => array('label' => false), 'class' => 'form form-horizontal')); ?> | |
<fieldset> | |
<h2><?php echo __('Assign Attendees'); ?></h2> | |
<hr /> | |
<div class="control-group"> | |
<?php echo $this->Form->input('Event', array('class' => 'input-block-level')); ?> | |
</div><!-- .control-group --> | |
<div class="control-group"> | |
<?php echo $this->Form->label('Attendee', 'Assign the following users:'); ?> | |
<?php echo $this->Form->input('Attendee', array( | |
'class' => 'input-block-level', | |
'multiple' => 'multiple', | |
'type' => 'select' | |
)); ?> | |
</div><!-- .control-group --> | |
</fieldset> | |
<hr /> | |
<div class="text-right"> | |
<?php echo $this->Form->submit('Save', array('class' => 'btn btn-large btn-success')); ?> | |
</div> | |
<?php echo $this->Form->end(); ?> | |
</div><!-- /.assignment.form --> | |
</div><!-- /.well --> | |
</div><!-- /.page-content --> | |
</div><!-- /.page-container --> | |
## ------------------------- | |
/** | |
* RESULTING POST DATA, FROM FORM: | |
array( | |
'Event' => array( | |
'Event' => array( | |
(int) 0 => '1' | |
) | |
), | |
'Attendee' => array( | |
'Attendee' => array( | |
(int) 0 => '1', | |
(int) 1 => '2' | |
) | |
) | |
) | |
* | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment