Welcome Guest, Not a member yet? Register   Sign In
conditional set_value()
#2

Hey,

I don't think there really an elegant way of handling this. This is the way I would do this: after the form is submitted and successfully validated, you could set a variable eg. anotherForm to true which you pass to your view. There you can check this variable and choose to not use set_value like so:

PHP Code:
// if anotherForm exists and is true, don't set the value entered earlier on
value="<?php echo (isset($anotherForm) and ($anotherForm == true)) ? '' : set_value('f_eventname'); ?>" 

Then there is you second question about the checkbox. The set_value() function is only used for inputs and textareas. For checkboxes you could do 2 things: 
1. use the form_checkbox function from the Form Helper to create your checkbox, which also handels the submitted value. See the user manual for the explanation: http://www.codeigniter.com/user_guide/he...m_checkbox 
2. you could use the set_checkbox function from the Form Helper which is like set_value. See the example taken from the user manual:

PHP Code:
<input type="checkbox" name="mycheck" value="1" <?php echo set_checkbox('mycheck''1'); ?> />
<input type="checkbox" name="mycheck" value="2" <?php echo set_checkbox('mycheck''2'); ?> /> 

The Form Helper has al sorts of functions 'helping' you with creating and processing forms. 

Hope this helps!

-Roger
Reply


Messages In This Thread
conditional set_value() - by dbrooke - 10-07-2016, 02:09 PM
RE: conditional set_value() - by RogerMore - 10-10-2016, 02:09 AM
RE: conditional set_value() - by PaulD - 10-10-2016, 04:22 AM
RE: conditional set_value() - by dbrooke - 10-10-2016, 08:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB