Welcome Guest, Not a member yet? Register   Sign In
internal message system message send form
#1

[eluser]mabright[/eluser]
I am working on an internal message system for my application and I have a compose message view that is at mysite.com/messages/compose.

On this form I have the post action as <?php echo current_url().'/send'; ?>.

I expect this to call my the compose method in my controller with a parameter of 'send' and that I can process the send logic accordingly.

The form submit (which is using a standard form button) just re-submits my compose page with /send in the URL instead of returning my test message that I put in place to see if the parameter is being passed.

Controller code below:
Code:
public function compose($action = '')
    {    
        if($action == 'send')
        {
              $msg_data['test_msg'] = 'This is a test';
        }        
        $msg_data = array('inbox_count' => $this->inbox_count,
                          'sent_count' => $this->sent_count,
                          'trash_count' => $this->trash_count);
        $data['column_main'] = $this->load->view('member/message_compose_view', $msg_data, TRUE);
        $this->_display('',$data);
        
    }

Am I doing this the correct way?
#2

[eluser]Aken[/eluser]
What happens if you go to the send page directly, IE type the URL into your browser. Does your test message pop up? If not, then it's not the form's problem.

Your code looks okay from what I can tell, but I haven't tested anything and could be missing something. A better description of what is not happening that should be would help some.
#3

[eluser]mabright[/eluser]
Below is my compose message view. I put a test variable($test_msg) in the view that I expect to print when my logic in the controller is called via the submitted "send message" button. I am new to CI and still testing the whole segment/parameter url logic.

Code:
<div id="mc_container">
    &lt;form method="post" action="&lt;?php echo current_url().'/send'; ?&gt;" enctype="multipart/form-data" /&gt;
        <div id="msg_boxsel_nav">
            <ul>
                <li &lt;?php if(stristr(current_url(),'compose') == true){echo 'class="selected_msg_box"';} ?&gt;>&lt;?php echo anchor('member/messages/compose',img('images/email_edit.png').' Compose Message'); ?&gt;</li>
                <li &lt;?php if(stristr(current_url(),'inbox') == true){echo 'class="selected_msg_box"';} ?&gt;>&lt;?php echo anchor('member/messages/inbox',img('images/email_open.png').' Inbox ('.$inbox_count.')'); ?&gt;</li>
                <li &lt;?php if(stristr(current_url(),'sent') == true){echo 'class="selected_msg_box"';} ?&gt;>&lt;?php echo anchor('member/messages/sent',img('images/email_go.png').' Sent'); ?&gt;</li>
                <li &lt;?php if(stristr(current_url(),'trash') == true){echo 'class="selected_msg_box"';} ?&gt;>&lt;?php echo anchor('member/messages/trash',img('images/bin_closed.png').'Trash'); ?&gt;</li>
            </ul>
        </div>
        <div id="msg_compose">
                <ol>
                    <li>
                        &lt;?php echo (isset($test_msg)) ? $test_msg : ''; ?&gt;
                    </li>
                    <li>
                        <label class="label_required">To:</label>
                        &lt;input class="msg_compose_input" type="text" name="input_recipients[]" id="input_recipients[]" value="&lt;?php echo set_value('input_recipients[]'); ?&gt;" tabindex="1"/&gt;                    
                    </li>
                    <li>
                        <label class="label_required">CC:</label>
                        &lt;input class="msg_compose_input" type="text" name="input_cc[]" id="input_cc[]" value="&lt;?php echo set_value('input_cc[]'); ?&gt;" tabindex="2"/&gt;                    
                    </li>
                    <li>
                        <label class="label_required">Subject:</label>
                        &lt;input class="msg_compose_input" type="text" name="input_subject" id="input_subject" value="&lt;?php echo set_value('input_subject'); ?&gt;" tabindex="3"/&gt;
                    </li>
                    <li>
                        &lt;textarea class="msg_compose_textarea" name="msg_body" id="msg_body" TABINDEX="4"&gt;&lt;/textarea>
                    </li>
                    <li>
                        <label class="label_required">Attachment:</label>
                        &lt;input type="file" name="input_attachment" id="input_attachment" value="" tabindex="5"/&gt;
                        <p class="msg_field_note">Allowed file types: gif, jpg and png. Max Size: 2M.</p>                
                    </li>
                    <li>
                        <label class="nolabel">.</label>
                        &lt;input name="send_msg" class="button" type="submit" value="Send Message" /&gt;
                    </li>
                </ol>
        </div>
    &lt;/form&gt;
</div>        
&lt;?php
/* End of file message_compose_view.php */
/* Location: /xvbapp/views/member/message_compose_view.php */
#4

[eluser]Aken[/eluser]
Okay, so what happens if you go to site.com/messages/compose/send directly, not through the form? Does the message appear?

I just tested your code minus the current_url() helper (kept giving me the example.com URL instead, not sure why), and hitting the button set the $action variable for me no problem.
#5

[eluser]mabright[/eluser]
Going directly to the send function, does not display the message.

I really just wanted to make sure my way I was using mvc was correct, i will keep trying to get the message to print. it's probably something small. thanks.




Theme © iAndrew 2016 - Forum software by © MyBB