sorry I was calling invalidFields wrong way there - think I have fixed
it!
On Aug 8, 12:45 pm, luke BAKING barker <[EMAIL PROTECTED]> wrote:
> Hi Geoff did you have any luck with getting this feature to work?
>
> Can I also thank you for your posts in this group on multiple saves as
> they've been very helpful.
>
> Coincidentally I am trying to get many RoomsTasks submitted from a
> form at once, and I have managed to loop through POSTed data and
> successfuly save it, from a form with inputs in form -
>
> data[RoomsTask][213][quantity_of_unit]
>
> data[RoomsTask][218][quantity_of_unit]
>
> data[RoomsTask][224][quantity_of_unit]
>
> etc(where I use the 224 to specify the task_id and I manipulate this
> in the controller before saving:
>
> foreach($this->data['RoomsTask'] as $taskIdNow => $roomsTask){
> // only if user checked the task,
> obviously:
> if ($roomsTask['task_id'] == 1) {
> // perform save code
> $this->RoomsTask->create();
> // assign all the fields with
> correct names
>
> // Todo: taken from a hidden
> field - take from session?
> $roomsTask['room_id'] =
> $this->data['Meta']['room_id'];
> $roomsTask['task_id'] =
> $taskIdNow; // we need to swap this
> value over, as it's a unique task we are adding!
> // priority?
>
> $this->RoomsTask->set($roomsTask); // this adds the
> quantity_of_unit also.
>
> //pr($this->RoomsTask->data);
> // Validation - tricky as
> need to remember the values too :/
> //
> if
> (!$this->RoomsTask->validates()) {
>
> // if it is Quantity
> - we must inform user of error, otherwise,
> we just don't Save it as a checkbox/hidden should validate!
> if
> (isset($this->RoomsTask->invalidFields['RoomsTask']
> ['quantity_of_unit'])) {
>
> $this->RoomsTask->invalidFields['RoomsTask']["$taskIdNow"]
> ['quantity_of_unit'] = $this->RoomsTask->invalidFields['RoomsTask']
> ['quantity_of_unit'];
>
> unset($this->RoomsTask->invalidFields['RoomsTask']
> ['quantity_of_unit']);
> }
>
> }
> else {
> $this->RoomsTask->save();
> $flashMsg .= 'saved ';
>
>
> //pr($this->RoomsTask->data);
>
> }
>
> }
>
> But I cannot get the validation and re-display of values working,
> since setting the $this->RoomsTask->invalidFields['RoomsTask']
> ["$taskIdNow"]['quantity_of_unit'] doesnt work.
>
> any ideas on how to re-display in the view values and error messages
> for appropriate fields?
>
> many thanks
>
> Luke
>
> On Jul 26, 12:27 am, Geoff Ford <[EMAIL PROTECTED]> wrote:
>
> > Hmm.. Very interesting. I had not seen that before. I might have a
> > play later on and see if I can get it to work. I'll let you know how
> > I go.
>
> > Geoff
> > --http://lemoncake.wordpress.com
>
> > On Jul 26, 8:49 am, chewie124 <[EMAIL PROTECTED]> wrote:
>
> > > Ahhh... ok. Thanks for the input. I was grepping thru the
> > > helpers.php library in the cake core, and it looks like in the
> > > setFormTag function , if there's a 3rd level branch,ie FormerEmployer.
> > > 2.name, the '2' will get parsed and tagged as the 'modelId'. Seems
> > > like though, the propigation hasn't made it back to the form helper,
> > > that can use the modelId to generate the input tags as you described
> > > above. Thanks for the input!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---