-
doomie22
Member
-
Posts: 58
Threads: 29
Joined: Feb 2016
Reputation:
-1
Hi,
I am having a small issue with form_hidden. If I have the following:
PHP Code: <?php echo form_input(array('id' => '1', 'name' => 'message_id', 'class' => 'form-control', 'value' => $tickettitle->message_id)); ?> <?php echo form_input(array('id' => '2', 'name' => 'title', 'class' => 'form-control', 'value' => $tickettitle->title)); ?>
When the following is processed it works.
PHP Code: public function process(){ $data = array( 'message_id' => $this->input->post('message_id'), 'user1' => $this->config->item('account_name'), 'user2' => 'pushmb', 'title' => $this->input->post('title'), 'message' => $this->input->post('message'), 'timestamp' => date("Y-m-d h:i:sa"), 'user1read' => '1', 'user2read' => '0', 'original' => '0' );
if (is_array($data) && count($data)>0){ $this->add_content_support($data, 'internal_messages'); $this->session->set_flashdata('success_message', $data['title'].' Successfully Added'); redirect('admin/support'); } else { $this->session->set_flashdata('error_message', $data['title'].' Failed to be Added'); redirect('admin/support'); } }
But I need them hidden, so I change it to the following:
PHP Code: <?php echo form_hidden(array('id' => '1', 'name' => 'message_id', 'class' => 'form-control', 'value' => $tickettitle->message_id)); ?> <?php echo form_hidden(array('id' => '2', 'name' => 'title', 'class' => 'form-control', 'value' => $tickettitle->title)); ?>
They some up as NULL and error the function. I have used hidden elsewhere and they are working fine so I have no idea why these are causing issues.
Doomie
-
Paradinight
Senior Member
-
Posts: 445
Threads: 6
Joined: Jun 2015
Reputation:
25
(06-22-2017, 05:10 PM)doomie22 Wrote: Hi,
I am having a small issue with form_hidden. If I have the following:
PHP Code: <?php echo form_input(array('id' => '1', 'name' => 'message_id', 'class' => 'form-control', 'value' => $tickettitle->message_id)); ?> <?php echo form_input(array('id' => '2', 'name' => 'title', 'class' => 'form-control', 'value' => $tickettitle->title)); ?>
When the following is processed it works.
PHP Code: public function process(){ $data = array( 'message_id' => $this->input->post('message_id'), 'user1' => $this->config->item('account_name'), 'user2' => 'pushmb', 'title' => $this->input->post('title'), 'message' => $this->input->post('message'), 'timestamp' => date("Y-m-d h:i:sa"), 'user1read' => '1', 'user2read' => '0', 'original' => '0' );
if (is_array($data) && count($data)>0){ $this->add_content_support($data, 'internal_messages'); $this->session->set_flashdata('success_message', $data['title'].' Successfully Added'); redirect('admin/support'); } else { $this->session->set_flashdata('error_message', $data['title'].' Failed to be Added'); redirect('admin/support'); } }
But I need them hidden, so I change it to the following:
PHP Code: <?php echo form_hidden(array('id' => '1', 'name' => 'message_id', 'class' => 'form-control', 'value' => $tickettitle->message_id)); ?> <?php echo form_hidden(array('id' => '2', 'name' => 'title', 'class' => 'form-control', 'value' => $tickettitle->title)); ?>
They some up as NULL and error the function. I have used hidden elsewhere and they are working fine so I have no idea why these are causing issues.
Doomie You use it wrong
https://www.codeigniter.com/user_guide/h...orm_hidden
-
Paradinight
Senior Member
-
Posts: 445
Threads: 6
Joined: Jun 2015
Reputation:
25
@ doomie22 Why down vote?
The link show how to use the form_hidden and show an exampla with form_input
PHP Code: $data = array( 'name' => 'John Doe', 'email' => '[email protected]', 'url' => 'http://example.com' );
echo form_hidden('my_array', $data);
/* Would produce:
<input type="hidden" name="my_array[name]" value="John Doe" /> <input type="hidden" name="my_array[email]" value="[email protected]" /> <input type="hidden" name="my_array[url]" value="http://example.com" /> */
PHP Code: $data = array( 'type' => 'hidden', 'name' => 'email', 'id' => 'hiddenemail', 'value' => '[email protected]', 'class' => 'hiddenemail' );
echo form_input($data);
|