Welcome Guest, Not a member yet? Register   Sign In
puzzling error msg in form validation controller
#21

[eluser]TheFuzzy0ne[/eluser]
CodeIgniter is smart, but sadly not smart enough to work properly when you make up your own methods for existing libraries. Tongue
#22

[eluser]oldnews[/eluser]
Mea culpa. I read the Email Function Reference wrong in the User Guide's Email Class page. Chalk it up to double vision from long hours of working to learn this framework. Now that THAT's fixed, each and every one of my variables is coming back undefined regardless of whether I omit the value fields, use just <?php set_value('n'); ?> or <?php echo set_value('n'); ?>, as below. I'll keep trying things until they work. The learning curve may not seem that steep, but I am working my ass off to get it right.

Code:
<html>
<head>
<title>Entry Form</title>
<LINK REL=StyleSheet href="http://uploadpixmaverik.com/style.css" type="text/css" media=screen>
</head>
<body>

<table cellpadding="0" cellspacing="0" border="0" width="800">
<tr>
<td class="red">Now, fill out our entry form &amp; submit it for a chance to win a trip to the 2009 Summer X Games in L.A.<br />
&nbsp;<br />

&lt;?php echo validation_errors(); ?&gt;

&lt;?php echo form_open('form'); ?&gt;

<center>
<table  border="0" cellspacing="2" cellpadding="2">
<tr>
<td align="right">your name:</td>
<td>&lt;input type="text" name="who" value="&lt;?php echo set_value('who'); ?&gt;" size="42" /&gt;&lt;/td>
<td align="right" colspan="2">primary phone:</td>
<td>&lt;input type="text" name="mainphone" value="&lt;?php echo set_value('mainphone'); ?&gt;" size="20" /&gt;&lt;/td>
</tr>
<tr>
<td align="right">email address:</td>
<td>&lt;input type="text" name="email" value="&lt;?php echo set_value('email'); ?&gt;" size="42" /&gt;&lt;/td>
<td align="right" colspan="2"><i>option add phone</i>:</td>
<td>&lt;input type="text" name="extraphone" value="&lt;?php echo set_value('extraphone'); ?&gt;" size="20" /&gt;&lt;/td>
</tr>
<tr>
<td align="right">mailing address:</td>
<td>&lt;input type="text" name="address" value="&lt;?php echo set_value('address'); ?&gt;" size="42" /&gt;&lt;/td>
<td align="right" colspan="2"><i>option alt phone</i>:</td>
<td>&lt;input type="text" name="altphone" value="&lt;?php echo set_value('altphone'); ?&gt;" size="20" /&gt;&lt;/td>
</tr>
<tr>
<td align="right">municipality:</td>
<td>&lt;input type="text" name="city" value="&lt;?php echo set_value('city'); ?&gt;" size="42" /&gt;&lt;/td>
<td> , <b>UTAH</b></td>
<td align="right">zip code:</td>
<td>&lt;input type="text" name="zip" value="&lt;?php echo set_value('zip'); ?&gt;" size="20" /&gt;&lt;/td>
</tr>
<tr>
<td align="right">describe photo:</td>
<td>&lt;input type="text" name="description" value="&lt;?php echo set_value('description'); ?&gt;" size="42" /&gt;&lt;/td>
<td align="right" colspan="2">photo location:</td>
<td>&lt;input type="text" name="location" value="&lt;?php echo set_value('location'); ?&gt;" size="20" /&gt;&lt;/td>
</tr>
<tr>
<td colspan="5">&nbsp;</td>
</tr>
<tr>
<td align="center" colspan="4">&lt;input type="checkbox" name="ageutresidency" value="TRUE"&gt; I certify I am a legal resident of Utah <b>AND</b> I am at least 18 years of age</td>
<td align="center">&lt;input type="submit" value="Submit" /&gt;&lt;/td>
</tr>
<tr>
<td colspan="5">&nbsp;</td>
</tr>
<tr>
<td align="right">if this fails, copy:</td>
<td>&lt;input type="text" name="photofile" value="&lt;?php echo $file_name;?&gt;" size="42" /&gt;&lt;/td>
<td colspan="3">and click <a href="http://uploadpixmaverik.com/alternate_entry.html">here</a> to paste and finish your entry</td>
</tr>
</table>
</center>

</td>
</tr>
</table>

&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;
#23

[eluser]TheFuzzy0ne[/eluser]
You're right that you need to echo the return value from set_value(). However, set value with only the first value set retrieves the value from the post array, which of course means that the form needs to have been submitted first. In this instance, it's only useful for when validation fails and the form is redisplayed to the user. If you want to insert default values, you'll need to pass a second parameter in to the set_value() function, which is the value you want to display if the forum has not yet been submitted.

I'm not entirely sure that this is what you're getting at though, so please let me know if I haven't answered your question.

If you need some more inspiration, check out my [url="http://ellislab.com/forums/viewthread/107773/"]CodeIgniter Resources thread[/url].




Theme © iAndrew 2016 - Forum software by © MyBB