0

I'm a little bit of a beginner to CakePHP and PHP in general, but I have OOP experience. I'm trying to make a mini Twitter to get used to the Cake framework.

I have a PostsController class that handles all creating blog posts, editing deleting etc, but I'm having trouble adding and add post form to the same page above the View Posts.

i.e. adding posts works fine when I link to a new page

    <p><?php echo $this->Html->link('Add Post', array('action' => 'add')); ?></p>

but while trying to put a form in the same page as the view I don't know how to call the 'add' action to save and use the data taken in in the form.

    echo $this->Form->create('Post',array('action' => 'add'));
    echo $this->Form->input('title');
    echo $this->Form->input('body', array('rows' => '3'));
    echo $this->Form->end('Save Post');

2 Answers 2

1
    echo $this->Form->create('Post', array('action' => 'add'));
    echo $this->Form->input('title');
    echo $this->Form->input('body', array('rows' => '3'));
    echo $this->Form->end('Save Post');

putting random arrays in your code will not do anything.

Sign up to request clarification or add additional context in comments.

Comments

0
  1. Missing semicolon after the array
  2. Not assigning or using the array in anything.
  3. Trying putting your array as the second parameter in the form create method.

1 Comment

that doesn't work, same thing, page refreshes but no post save. Thanks anyway for the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.