Welcome Guest, Not a member yet? Register   Sign In
Function to generate this code (with variables)
#1

[eluser]bapobap[/eluser]
Hi there,

I'm making lots of form items and they are pretty much standardised, so I thought why not make a nice helper function to make it simpler but I don't know how to have the variable I need to use in the actual code. Example:
Code:
&lt;?php if ($this->validation->VAR_error): echo '<div class="error">'; else: echo '<div class="item">'; endif; ?&gt;
<p><label for="VAR">VAR_LABEL</label>&lt;?=$this->validation->VAR_error?&gt;</p>
<p>&lt;input type="VAR_TYPE" id="VAR" name="VAR" value="&lt;?=$this-&gt;validation->VAR?&gt;" class="text" /></p>
</div>

Somehow generate that, replacing the variables, using a function call like this:
Code:
&lt;?=nice_form_item('email', 'text', 'Email address')?&gt;

Is there any way to do this, or maybe even a better way?

Thanks!


Messages In This Thread
Function to generate this code (with variables) - by El Forum - 09-19-2008, 02:21 PM
Function to generate this code (with variables) - by El Forum - 09-19-2008, 05:09 PM
Function to generate this code (with variables) - by El Forum - 09-19-2008, 05:18 PM
Function to generate this code (with variables) - by El Forum - 09-19-2008, 05:24 PM
Function to generate this code (with variables) - by El Forum - 09-19-2008, 05:27 PM
Function to generate this code (with variables) - by El Forum - 09-19-2008, 05:43 PM
Function to generate this code (with variables) - by El Forum - 09-19-2008, 05:53 PM
Function to generate this code (with variables) - by El Forum - 09-19-2008, 06:06 PM
Function to generate this code (with variables) - by El Forum - 09-19-2008, 06:12 PM
Function to generate this code (with variables) - by El Forum - 09-19-2008, 06:33 PM
Function to generate this code (with variables) - by El Forum - 09-19-2008, 06:37 PM
Function to generate this code (with variables) - by El Forum - 09-20-2008, 11:49 AM



Theme © iAndrew 2016 - Forum software by © MyBB