thanks again Dardo,
I got the date working, although I also had to add the 'minYear' also
or else we only have very young students ;)

Also got the search function to work with only a little tinkering.
Took me a while to realise that I needed to change the form to: '<?php
echo $form->create('Student', array('action' => 'search')); ?>'
but that was straight forward.  I also needed to change the flash
message to $this->Flash('Student not found','/students/search');

Am I correct in assuming that I will need to put in different search
functions for each type of search I want to do.  Eg. studentsearch,
coursesearch?  Where coursesearch returns all the students doing the
course (I would also need a different view function also, or could I
just manipulate my viewall function, because that is how I would like
it presented).

Now I'm really getting somewhere!  Albeit with my hand held :)


On Mar 23, 5:16 pm, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote:
> On Sun, Mar 23, 2008 at 3:00 AM, damo <[EMAIL PROTECTED]> wrote:
>
> >  Thanks Dardo, I have taken your advise and added the additional
> >  field.  It all seems to work great now, I'm suprised with how quickly
> >  things come together even on my first attempt.  So now I have an add,
> >  edit, delete, view functions.  All of this is based of the tutorial
> >  and I am very pleased with my progress but I am quickly realising how
> >  much more there is to it!!
>
> You are wecome, I'm glad you are making progress, cake is so powerful.
>
> >  A couple of more questions:
> >  I have a 'date' field which is for Date of Birth.  In the addformas
> >  it is it lists dates from 1988 to 2028.  I obviously don't need future
> >  dates for this, so how can I change this so that the latest date is
> >  today (or some arbitrary recent date), and it's earliest date is back
> >  x amount of years.
>
> $form->input('mydatefield', array('maxYear' => 2008));
>
> >  Second, I would like to put together a very simple search function
> >  preferably based upon the tutorial (because I understand that).  I
> >  haven't been able to find anything particularly easy to implement in
> >  my reading so far.  All I really want to do is search for the
> >  'student_number' and then 'view' that record, failing that echo
> >  'student doesn't exist', or something like that.
>
> This may work,
>
> in your controller :
>
> function search() {
>
> if (!empty($this->data)) {
>      $number = $this->data['Student']['student_number'];
>      $student = $this->Student->findByStudentNumber($number);
>     // or : $student =
> $this->Student->find(array('Student.student_number' => $number));
>
>      if ( $student) {
>         $this->redirect(array('action' => 'view', $student['Student']['id']));
>      } else {
>         $this->Session->setFlash('Student not found');
>      }
>
> }
> >  On Mar 22, 7:04 pm, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote:
> >  > Cake automagically sets primary keys fields as hidden, you can
> >  > override the default behavior:
>
> >  > echo $form->input('id', array('label' => 'Student Number: ', 'type' => 
> > 'text'));
>
> >  > Maybe is better, just to add a new field called student_number and
> >  > make it an sql unique index and let the ids alones.
>
> > > On Sat, Mar 22, 2008 at 2:41 AM, damo <[EMAIL PROTECTED]> wrote:
>
> >  > >  I'm sure this is ridiculously simple to resolve, but the below seems
> >  > >  to work perfectly:
>
> >  > >  <h1>Add Student Record</h1>
>
> >  > >  <?php echo $form->create('Student'); ?>
>
> >  > >   <?php
> >  > >         echo $form->input('id', array('label' => 'Student Number: '));
> >  > >         echo $form->input('studentname', array('label' => 'Student
> >  > >  Name: '));
> >  > >         echo $form->input('studentdob', array('label' => 'Student Date
> >  > >  of Birth: '));
> >  > >         echo $form->input('course', array('label' => 'Current Course:
> >  > >  '));
> >  > >   ?>
>
> >  > >  <?php echo $form->end('Insert'); ?>
>
> >  > >  except that the id component of theformdoesn't display at all....
> >  > >  When I insert the record, everything goes in correctly, except
> >  > >  obviously the the 'id'.  The 'id' is set as the primary key for the
> >  > >  table, although I have toggled this.  Also, I would have preferred to
> >  > >  have the 'id' labelled something like 'studentnumber', but the view
> >  > >  option wouldn't work when I had it setup this way.
>
> >  > >  Many thanks,
> >  > >  Damo
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to