Re: Generating multiple 'requests' based on form selections

2013-06-30 Thread David Suna
I think your use of the term request is confusing. Do you need the client 
to issue six requests to the server with the various combinations? Or can 
the client issue a single request with all of the information and have the 
server process that as a request for six new records to be created?

If you need to actually issue six separate requests then the way I could 
think of doing it would be using JavaScript. Capture the submit button 
event and then use AJAX calls to issue the separate requests. This is a 
very messy way to do it as you would need to build into the client error 
handling and roll back for partially executed requests.

If you can have the single request then basically all of the work happens 
on the server.  I haven't used CakePHP 1.1 but in 1.3 you could generate an 
array of the model you want to save and call saveAll.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.




Generating multiple 'requests' based on form selections

2013-06-27 Thread David Carr


I have a CakePHP form that lets a user select a variety of parameters. What 
I want to do is let them select multiple choices on a few different 
parameters, and then turn these into multiple submissions. My CakePHP model 
is called 'Requests' so ideally what I want to do is have the user be able 
to create multiple requests through one form submission - essentially a 
'cross-product' of the options they choose.

I don't want/need anyone to write code for me but if someone could help me 
think this problem through and give me a few pointers in the right 
direction, I'd greatly appreciate it!

Disclaimer: I'm using CakePHP 1.1, and am unable to upgrade - this site 
runs on the same machine as many others inside my company and there was 
lots of hackery done and lots of shared files.  Disclaimer #2, I am an 
intern and brand new to CakePHP ;-)

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Generating multiple 'requests' based on form selections

2013-06-27 Thread Robert Gravel
Not sure if this is what you want to do but I have a view with 2 form
elements on it. I did get hung up because I usually use $this-Form-end

?php
 echo $this-Form-create('User', array( 'action'='/add_staff'));?
fieldset
 legend?php __('Admin Add Staff Member'); ?/legend
?php
echo $this-Form-input('id', array('label' = 'Select an existing
Student','options' = array(  $users)));
echo By submitting this form you are giving the selected student
Administrative access;
echo $this-Form-hidden('group_id', array('value' = '1'));
echo br;
?
/fieldset
?php
echo $this-Form-submit('Add a Staff Member from an existing
Student', array('name' = 'submit'));
echo br;
echo -- OR -- Create a new profile for this Staff Member. ;
echo br;
?
?php echo $this-Form-create('User2', array(
'action'='/add_staff'));?

fieldset
 legend?php __('Add a New Staff Member '); ?/legend
?php

echo $this-Form-input('first_name');
echo $this-Form-input('last_name');
echo $this-Form-input('username');
echo $this-Form-input('password');
echo $this-Form-input('email');
echo $this-Form-input('birthdate', array('label' = 'Date of
Birth', 'empty' = true, 'timeFormat' = '', 'minYear' = ( date('Y') - 70
), 'maxYear' = ( date('Y') - 3)));
echo $this-Form-input('address');
echo $this-Form-input('city');
echo $this-Form-input('state');
echo $this-Form-input('zip_code');
echo $this-Form-input('phone');
echo $this-Form-input('uniform_size', array( 'type' = 'select',
'options' = array( '' = 'Size ', '000' = 'Size 000', '00' =
'size 00', '0' = 'Size 0', '1' = 'Size 1', '2' = 'size 2' , '3' = 'Size
3', '4' = 'size 4', '5' = 'Size 5', '6' = 'Size 6')));
echo $this-Form-input('is_head', array('type'='checkbox'));
echo $this-Form-input('household_id');
echo $this-Form-hidden('group_id', array('value' = '1'));
echo $this-Form-input('school_id', array( 'value' =
$currentSchool , 'type' = 'hidden') );

?
/fieldset
?php
//echo $this-Form-end(__('Submit', true));
echo $this-Form-submit('Add a Staff Member', array('name' = 'submit'));

controller:

if (isset($this-params['form']['submit'])){
//check for first form
if ($this-params['form']['submit'] == Add a Staff Member from
an existing Student){
if ($this-User-save($this-data)) {
$this-Session-setFlash(__('The user has been saved',
true));
$this-redirect(array('action'='view_staff'));
} else {
$this-Session-setFlash(__('The user could not be saved.
Please, try again.', true));
}
//check for second form
}elseif ($this-params['form']['submit'] == 'Add a Staff
Member'){
//give value of second form (User2) to User so it can be
automatically saved
$this-data['User'] = $this-data['User2'];
//save the data
if ($this-User-save($this-data)) {
$this-Session-setFlash(__('The user has been saved',
true));
$this-redirect(array('action'='view_staff'));
} else {
$this-Session-setFlash(__('The user could not be saved.
Please, try again.', true));
}
}
}


On Thu, Jun 27, 2013 at 1:19 PM, David Carr dc...@scienceprousa.com wrote:

 I have a CakePHP form that lets a user select a variety of parameters.
 What I want to do is let them select multiple choices on a few different
 parameters, and then turn these into multiple submissions. My CakePHP model
 is called 'Requests' so ideally what I want to do is have the user be able
 to create multiple requests through one form submission - essentially a
 'cross-product' of the options they choose.

 I don't want/need anyone to write code for me but if someone could help me
 think this problem through and give me a few pointers in the right
 direction, I'd greatly appreciate it!

 Disclaimer: I'm using CakePHP 1.1, and am unable to upgrade - this site
 runs on the same machine as many others inside my company and there was
 lots of hackery done and lots of shared files.  Disclaimer #2, I am an
 intern and brand new to CakePHP ;-)

 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to cake-php+unsubscr...@googlegroups.com.
 To post to this group, send email to cake-php@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter 

Re: Generating multiple 'requests' based on form selections

2013-06-27 Thread David Carr
Thanks - this is a little different than what I'm looking to do.  Yours is 
two forms on the same page, I want mine to be one form - but based on the 
selectison the user makes - say they make 3 selections in one multi-select, 
and 2 in another - I want my controller to be able to take the data and 
form 6 requests that get saved as six different 'instances' of my model. 
 Sorry if my terminology is a bit off.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.