Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6987071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:53:22+00:00 2026-05-27T18:53:22+00:00

Imagine a form like this: <form action=test.php method=post> <input type=text name=firstname value=<?=set_value(‘firstname’)?> /> <input

  • 0

Imagine a form like this:

<form action="test.php" method="post">
    <input type="text" name="firstname" value="<?=set_value('firstname')?>" />
    <input type="text" name="lastname" value="<?=set_value('lastname')?>" />
    <input type="text" name="email" value="<?=set_value('email')?>" />
    <input type="submit" name="submit_form" value="OK" />
</form>

If I submit an incorrect email, the CodeIgniter function will write “the field is not valid” and populate the invalid field with the wrong value.

I would like to keep the error message but not the wrong value (I prefer having an empty value). But I also want to keep the re-populating function for correct values.

Here is what I get:

http://nsa21.casimages.com/img/2011/12/29//111229060041170572.jpg

Here is what I want:

enter image description here

[EDIT] SOLUTION FOUND (thanks to Herr Kaleun and Matt Moore)

Example with the email field:

<input type="text" name="email" id="email" value="<?=!form_error('email')?set_value('email'):''?>" />
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:53:23+00:00Added an answer on May 27, 2026 at 6:53 pm

    You can check the fields individually and have a logic like this.

    If the error for a specific field is present, you can build a logic on top of that.

    if ( form_error('email') != '' )
    {
        $data['email_value'] = '';
    }
    else
    {
        $data['email_value'] = set_value('email');
    }
    
    <form action="test.php" method="post">
        <input type="text" name="firstname" value="<?=set_value('firstname')?>" />
        <input type="text" name="lastname" value="<?=set_value('lastname')?>" />
        <input type="text" name="email" value="<?= $email_value; ?>" />
        <input type="submit" name="submit_form" value="OK" />
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Imagine this simple form <form action=<?php echo $_SERVER['REQUEST_URI']; ?> method=post> <fieldset> <legend>Contact Me</legend> <label
Let's imagine I got this: index.php generates form with unpredictable number of inputs with
I often want to write something like this: new Form { Text = Caption,
I have the folowing gsp page: <g:form controller=?? action=??> <h1>Search</h1> <g:submitButton name=search value=Search/> <div
Imagine a user that would like to put a form on their website that
I have an input field on a page that looks something like this: <input
Imagine you have a form where you switch visibility of several fields. And if
imagine that I have a Form with 9 controls (TabbedStuffControl) in a 3x3 tile,
I'm passing form variables in a cfinvoke argument collection: <cfinvoke component=#application.componentPath#.account method=updateServices argumentcollection=#form# />
I have a Generic class like this : public class Mapper<TEntity, TDataAccess> where TEntity

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.