[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:
<?php if ($this->validation->VAR_error): echo '<div class="error">'; else: echo '<div class="item">'; endif; ?>
<p><label for="VAR">VAR_LABEL</label><?=$this->validation->VAR_error?></p>
<p><input type="VAR_TYPE" id="VAR" name="VAR" value="<?=$this->validation->VAR?>" class="text" /></p>
</div>
Somehow generate that, replacing the variables, using a function call like this:
Code:
<?=nice_form_item('email', 'text', 'Email address')?>
Is there any way to do this, or maybe even a better way?
Thanks!