Welcome Guest, Not a member yet? Register   Sign In
Sharing a view file for Add and Edit functions
#1

[eluser]digitalbloke[/eluser]
Good evening.

I have a controller with two functions. One to add a news article and another to edit. Currently each function has a separate view file. Keeping DRY in mind I'm trying to replace the two view files with one. Where I'm getting stuck is with the set_value() function. As obviously for the add view the second parameter of set_vaule() has not been set and therefore causes php to show an "Undefined variable" error.

I could do something like this, but sometimes it gets a bit long and messy:
Code:
<?php echo set_value('title', ( isset($title) ) ? $title : ''); ?>

I've also come across this wiki article:
http://codeigniter.com/wiki/Add_Edit_Views/

But I'm not too keen on using the @ symbol to suppress php errors and was wondering if anyone could point me in the direction of a better way to solve this problem.

Thanks in advance.

Smile


Messages In This Thread
Sharing a view file for Add and Edit functions - by El Forum - 04-05-2010, 12:27 PM
Sharing a view file for Add and Edit functions - by El Forum - 04-05-2010, 03:55 PM
Sharing a view file for Add and Edit functions - by El Forum - 04-05-2010, 04:06 PM
Sharing a view file for Add and Edit functions - by El Forum - 04-05-2010, 07:48 PM
Sharing a view file for Add and Edit functions - by El Forum - 04-07-2010, 05:36 AM
Sharing a view file for Add and Edit functions - by El Forum - 04-07-2010, 08:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB