You redirect using the the ID on condition of the data being saved
$this->Post->create();
if ($this->Post->save($this->data)) {
$this->Session->setFlash(__('Please review the post before
activiating', true));
$this->redirect(array('action' => 'previewpost',
$this->Post->id));
} else {
........
$this->Session->setFlash(__('The post could not be saved.
Please, try again.', true));
}
- S
On 10 February 2011 09:36, Sam Sherlock <[email protected]> wrote:
> I would have a field in the post model published/active
>
> when a post is added it is not published; after the post is added (and
> saved as unpublished/inactive)
> the controller redirects to the previewpost as of the same controller, if
> the save is successful
> (otherwise remains on same action validation errors to be corrected of
> whatever)
>
> the post file would use an upload behaviour (a few exist to choose from;
> and the tv site has instructional video for at least one of these)
>
> then the previewpost updates the post setting it to be active/published
>
> post
> id int(11) auto incre
> user_id (relating to user)
> title varchar(125)
> description varchar(255)
> file varchar(225)
> active int(1)
> created datetime
> modified datetime
>
>
> hth - S
>
>
>
>
>
> On 10 February 2011 02:25, zer0_gravity <[email protected]> wrote:
>
>> Firstly I would like to make my apologies for not being clear enough
>> in my initial explanation.
>>
>> I am trying to build a document library where multiple users can login
>> to upload or view document files(pdf,txt,doc) and other users can post
>> comments on documents uploaded.
>>
>> I have a controller named posts with 2 action (previewpost, addpost)
>> so far.
>>
>> The addpost action should send the $this->data to another action named
>> previewpost and then redirect the current view to the
>> (previewpost.ctp) view. The content of $this->data was gathered from a
>> html form post in the (addpost.ctp) view.
>>
>> Inside the (previewpost.ctp) view it will show the content of the new
>> post submit by (addpost.ctp) view and then the action for the
>> (previewpost.ctp) view will determine if the user wishes save or
>> discard the info submitted by the (addpost.ctp) view.
>>
>> I would like to know if an action can send info to other actions
>> inside other controllers. For instance controller A action
>> is insideA and controller B action is insideB then can the two
>> controllers send info to each thru their actions?
>>
>> I hope this is any clearer unfortunately I am unable to provide you
>> with any code snippet because I am stump and I am not sure as to how
>> to proceed any further.
>>
>> thanks for your help everyone.
>>
>> On Feb 9, 2:30 pm, Sam Sherlock <[email protected]> wrote:
>> > This is the second time you have asked this question.
>> >
>> > Like the first time the question is lacking information, required to
>> give
>> > you an informative answer
>> >
>> > you are better off describing what you are trying to do
>> > and providing info on what you have tried (with code samples)
>> >
>> > this way others can understand your goal and will be in a better
>> position to
>> > provide
>> > an answer
>> > --
>> >
>> > With a Controller Posts (an action has a corresponding view a ctp file
>> in
>> > views/<CONTROLLERNAME>/)
>> >
>> > it may have multiple actions eg
>> > index - all posts
>> > view - a single post viewed by id
>> >
>> > so pass the id from index to view, so that
>> > the view displays a post item.
>> >
>> > in the view for the action `views/posts/index.ctp`
>> > you use the echo $html->link('read more >>', array('action' => 'view',
>> > $post['Post']['id']));
>> > assuming you are within a foreach loop
>> >
>> > ---
>> >
>> > although you might be asking how to access a property in one method
>> > when you have assigned it from another method.
>> >
>> > actions of controllers are methods not all methods are actions
>> >
>> > you should read up on object orientated programming
>> > and the concept of MVC.
>> >
>> > - S
>> >
>> > On 9 February 2011 18:56, zer0_gravity <[email protected]> wrote:
>> >
>> >
>> >
>> > > How can I in cake forward data from one action to another action
>> > > within the same
>> > > controller?
>> >
>> > > --
>> > > Our newest site for the community: CakePHP Video Tutorials
>> > >http://tv.cakephp.org
>> > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
>> > > others with their CakePHP related questions.
>> >
>> > > To unsubscribe from this group, send email to
>> > > [email protected] For more options, visit this
>> group
>> > > athttp://groups.google.com/group/cake-php
>>
>> --
>> Our newest site for the community: CakePHP Video Tutorials
>> http://tv.cakephp.org
>> Check out the new CakePHP Questions site http://ask.cakephp.org and help
>> others with their CakePHP related questions.
>>
>>
>> To unsubscribe from this group, send email to
>> [email protected] For more options, visit this group
>> at http://groups.google.com/group/cake-php
>>
>
>
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php