Thanks, this is along the lines of what I am looking for.
Why AJAX though? Is it possible for me to list all rows and have an
editable textfield for only the new field I added? If so, would
updateAll() work as in grigri's idea?
Also, if I wanted to make this applicable for several models, would I
have to make this a Behavior (or Helper)? Is it even possible to do
so, given the scenario I outlined?
Sorry for confusing with the Excel-export idea, I was just suggesting
that saying it sounded easier to me than writing this sort of code. I
would like to do it in native CakePHP, if possible, especially since I
am going to end up with several such tables soon. :)
Thanks,
SumanRS
On Apr 29, 5:20 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hmm, I'm not sure updateAll will work in this case. It will work fine
> if you want to update all rows with the same data but not otherwise.
> If you want it to behave more like excel, where you can edit all
> fields of all rows (or at least paginated rows) here's what I'd do:
>
> 1) Select all rows in your controller
> 2) In your view, inside a foreach($results as $result) loop generate a
> new ajax form for each row in your results. with input fields for each
> field in that particular row.
> 3) here, you can do a couple things: 1) generate a separate ajax
> button for each form that submits to an update function that saves
> that particular row and refreshes the row's div. OR 2) to make it more
> like excel, make the ajax button hidden (ie display none) and put in a
> javascript function that submits the ajax button during the onChange
> of each field in the row. sort of an "Autosave" feature.
>
> OR
>
> you could generate inputs for each field incremently named (ie
> name="Model.1.someField", name="Model.1.anotherField" name
> ="Model.2.someField", name="Model.2.anotherField" etc) and submit all
> data with the same button and then in your controller go through your
> data with a foreach loop and save each one ( foreach($this-
>
> >data["Model"] as $model){$this->Model->save($model)} )
>
> On Apr 29, 10:53 am, grigri <[EMAIL PROTECTED]> wrote:
>
> > $this->YourModel->updateAll(array('new_field' => 'new_value'),
> > array('1=1'));
>
> > Note that you'll have to quote/escape the value yourself.
>
> > On Apr 29, 4:27 pm,SumanRS<[EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > I've been using CakePHP for creating an online version of a listing
> > > that has long been maintained using Excel. There are several hundred
> > > rows in this table.
>
> > > However, one thing where the Excel UI wins is in allowing a new field
> > > (column) to be added. After that, it is easy to update the field for
> > > all rows. If I wanted to do this in Cake, I would have to click "Edit"
> > > on each row and edit the value for the field for each row.
>
> > > One way I can think of solving this is:
> > > 1. Export the CakePHP values to a CSV
> > > 2. Edit the CSV in Excel
> > > 3. Write PHP to open the edited CSV and update the fields (I've done
> > > this before)
>
> > > Is there a way to do this natively (and easily) in CakePHP?
>
> > > Thanks,
> > >SumanRS
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---