CodeIgniter Forums
value pssing - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: value pssing (/thread-33525.html)



value pssing - El Forum - 08-30-2010

[eluser]jis[/eluser]
hai to all how to pass a value from view to the controller file pls help is ther any code with u..?


value pssing - El Forum - 08-30-2010

[eluser]WanWizard[/eluser]
A view doesn't generate data, it only displays it.

What kind of information do you want to pass? Example?


value pssing - El Forum - 08-30-2010

[eluser]jis[/eluser]
actually i just want to call a function that is in controlleris that possible
example

Controller.php
class helo extends controller
{ function index()
{
}
function sample()
{echo "fgg""
}
}
view.php
somthing like this....
$this->sample();

is this possible i dont know i am asking any junks becz i am new this concept..


value pssing - El Forum - 08-30-2010

[eluser]WanWizard[/eluser]
The standard way of working is the other way around.

If you need information from a method (model, library or controller), you do
Code:
$data['sample'] = $this->sample();
$this->load->view('viewfile', $data);

and then the result of the sample() method is available in your view via $sample.

You should never generate output outside the output class.
If output compression is off, it will end up at the wrong place, if it is on, you end up with a blank page.


value pssing - El Forum - 08-30-2010

[eluser]jis[/eluser]
thank WanWizard you that will also solve my prblm thnk you for spending time for me


value pssing - El Forum - 08-30-2010

[eluser]jis[/eluser]
how it done in this case

<?php if(isset($_POST['blogs']))
................
?>


</ol>
&lt;form name="f1" method="post"&gt;
&lt;input type="submit" name="blogs" id="blogs" value="blog" /&gt;
&lt;/form&gt;

i need to display the content of a methods in cotroller in the button action is that possible


value pssing - El Forum - 08-30-2010

[eluser]WanWizard[/eluser]
Another tip: do not ever use unvalidated and unfiltered information anywhere in your application, so no references to $_POST. Anything can be posted, you can't trust its content.

This works the same as the previous example:
Code:
$data['sample'] = $this->sample();
$data['has_blogs'] = $this->input->post('blogs', TRUE);
$this->load->view('viewfile', $data);

In your view:
Code:
<php if ( $has_blogs )
{
    // blog code here
}?&gt;



value pssing - El Forum - 08-31-2010

[eluser]jis[/eluser]
thank u WanWizard could you pls do me one for favor pls....
pls give me sample code that will help me to under stand the data flow of mvc in CI pls
for exapmle a take value from databse and display it in the text box...... pls


value pssing - El Forum - 09-01-2010

[eluser]bretticus[/eluser]
[quote author="jis" date="1283336257"]thank u WanWizard could you pls do me one for favor pls....
pls give me sample code that will help me to under stand the data flow of mvc in CI pls
for exapmle a take value from databse and display it in the text box...... pls[/quote]

Have you not watched the introduction screen cast tutorials? Here is the link with links to other helpful tutorials.