Pretty much this:

function filter($filter_id = null) {
  if (empty($filter_id) && !empty($this->data['Lead']['employee'])) {
    $filter_id = $this->data['Lead']['employee'];
  }
  // Rest of code here
}

hth
grigri

On Jul 21, 11:00 am, james <jamesliv...@googlemail.com> wrote:
> Thanks grigiri - i'll get on it!
>
> out of interest, how would that be accomplished by usnig the data[]
> instead of passing the id parameter? It would be useful i guess to
> avoid the redirect every time if possible
>
> On 21 July, 10:27, grigri <j...@hendersonwebdesign.com> wrote:
>
> > Ok, this setup will give you a post-redirect-get mechanism.
>
> > You could also forgo the requirement for the id to be passed as a
> > parameter, and just use the posted data[] - this would avoid the
> > redirect.
>
> > Some kind of validation would be good to add, too.
>
> > View:
>
> > <?php
> > echo $form->create('Lead', array('action' => 'filter'));
> > echo $form->input(...);
> > echo $form->end('Go');
> > ?>
>
> > Controller:
>
> > function filter($filter_id = null) {
> >   if (empty($filter_id) && !empty($this->data['Lead']['employee'])) {
> >     $this->redirect(array('action' => 'filter', $this->data['Lead']
> > ['employee']));
> >   }
> >   // Rest of code here
>
> > }
>
> > hth
> > grigri
>
> > On Jul 21, 10:20 am, james <jamesliv...@googlemail.com> wrote:
>
> > > Im having a real noob time with this!
>
> > > Im trying to refine the information that is represented in an index
> > > based on the selection from a combo box which has a list of employees.
> > > The user selects the employee they want, clicks go and view then gets
> > > refined to all records associated to that employee_id.
>
> > > so in my controller I have
>
> > > function filter($filter_id = null){
> > >   $filterQuery = $this->Lead->find('all',
> > >                         array(
> > >                            'conditions'=>array(      'Lead.employee_id' 
> > > => $filter_id)));
> > > $this->set->('filterQuery', $filterQuery);
>
> > > and my index view I have
>
> > >  <?php echo $form->input('employee', array
> > >                         ('label' => '',
> > >                         'type' => 'select',
> > >                         'options' => array($employee),   ));?>
> > > <?php echo $form->end('Go');?>
>
> > > Do i need to link that action to a comnpletely different view eg
> > > filter.ctp? How do i call the method and pass the id?
>
> > > Please help!
>
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to