You don't have to save the records that would put a blank row in your
table.
What validation rules are you using now? You can set some of your
fields as 'notEmpty' or 'required'. You stated you are using saveAll
(); are you aware of the validate option for saveAll()?
http://teknoid.wordpress.com/2008/08/01/practical-use-of-saveall-part-1-working-with-multiple-models/
For more information on validation see the links I posted earlier.
-teh
On May 25, 8:32 pm, cakephp101 <valenzuela...@gmail.com> wrote:
> because i have a list of the timesheet in a table and it looks odd to
> have a blank row in the table.
>
> On May 25, 7:45 pm, andy <andy.baugh...@gmail.com> wrote:
>
> > Why not allow the blank record to save as NULL?
>
> > On May 24, 9:01 pm, cakephp101 <valenzuela...@gmail.com> wrote:
>
> > > thanks for the reply but the thing is it's ok for the field to be
> > > empty but it should not be saved in the database. i'm using foreach
> > > loop for my saveAll for each of the fields so i want to know how to
> > > abort the save for the empty ones.
>
> > > On May 22, 11:12 pm, forrestgump <vikhya...@gmail.com> wrote:
>
> > > > Just follow the links provided by Teh Treag . Basically u need to
> > > > define the validation function in your Model to make sure the field it
> > > > not empty .
>
> > > > forrestgump
>
> > > > On May 22, 12:06 pm, cakephp101 <valenzuela...@gmail.com> wrote:
>
> > > > > how? i'm sorry i just learned cakephp few weeks ago.
>
> > > > > On May 22, 2:52 pm, "Dr. Loboto" <drLob...@gmail.com> wrote:
>
> > > > > > You should use validation for it.
>
> > > > > > On May 22, 12:15 pm, cakephp101 <valenzuela...@gmail.com> wrote:
>
> > > > > > > yes, i mean fields in a table. i'm doing a timesheet for a payroll.
> > > > > > > the start sched, end sched, time in and time out of the employee are
> > > > > > > the input. that means i have 4 fields. i have 5 rows of those 4
> > > > > > > fields. the 5 rows is equal to 5 days because 1 row is equal to 1 day.
> > > > > > > when i only put input in 4 of the rows and 1 form is empty, it will
> > > > > > > still save the empty fields with a null value in my database. i'm
> > > > > > > saving it through saveAll. how can i abort the save for the fields
> > > > > > > that are empty? i think it should be done in beforeSave but i don't
> > > > > > > know how.
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment