Welcome Guest, Not a member yet? Register   Sign In
Issue with Validation library
#1

[eluser]awpti[/eluser]
Okay, running the latest - 1.6.3

Problem: http://ignitedjobs.com/addjob/

Explanation:
Following the examples in the User Guide results in notices that $this->validation->...var here... is not set. This goes away if I submit with even just one field filled in.

I tried to avoid it by abusing ternary operators (yuck to that attempt), but I just can't figure out the cause. According to the UG, this is how it should be done.

The Controller:

Code:
function validate()
        {
                $this->view->part('header', 'tpl/header');
                $this->view->part('footer', 'tpl/footer');

                // Set the validation rules.
                $rules = array
                (
                        'location'      => 'required|xss_clean',
                        'company'       => 'xss_clean',
                        'email'         => 'required|valid_email',
                        'job_title'     => 'required|xss_clean',
                        'description'   => 'required|xss_clean',
                        'to_apply'      => 'required|xss_clean',
                        'website'       => 'required|prep_url|xss_clean'
                );

                $fields = array
                (
                        'location'      => 'Location',
                        'company'       => 'Company',
                        'email'         => 'E-Mail',
                        'job_title'     => 'Job Title',
                        'description'   => 'Description',
                        'to_apply'      => 'How to Apply',
                        'website'       => 'Website'
                );

                $this->validation->set_rules($rules);
                $this->validation->set_fields($fields);

                if ($this->validation->run() == FALSE)
                {
                        $this->view->load('add_job');
                }
                else
                {
                        redirect('/addjob/accepted', 'header');
                }
        }

The View:

Code:
if($this->validation->error_string) { echo '<div class="notlive"><p>'.$this->validation->error_string.'</p></div>'; }

echo form_open('addjob/validate', array('id' => 'jobs', 'class' => 'cssform'));

echo '<p><label for="email"><span style="color: red">E-Mail</span>:</label>';
echo form_input(array('id' => 'email', 'name' => 'email', 'value' => $this->validation->email));
echo '<br />Required to edit entry.';
echo '</p>';

echo '<p><label for="company">Company Name:</label>';
echo form_input(array('id' => 'company', 'name' => 'company', 'value' => $this->validation->company));
echo '<br />Example: Ignited Jobs, Inc';
echo '</p>';

echo '<p><label for="job_title"><span style="color: red">Job Title</span>:</label>';
echo form_input(array('id' => 'job_title', 'name' => 'job_title', 'value' => $this->validation->job_title));
echo '<br />Example: Need an experienced Developer!';
echo '</p>';

echo '<p><label for="location"><span style="color: red">Location</span>:</label>';
echo form_input(array('id' => 'location', 'name' => 'location', 'value' => $this->validation->location));
echo '<br />Example: Phoenix, AZ or Freelance/Remote';
echo '</p>';

echo '<p><label for="website"><span style="color: red">Website</span>:</label>';
echo form_input(array('id' => 'website', 'name' => 'website', 'value' => $this->validation->website));
echo '<br />Example: http://ignitedjobs.com';
echo '</p>';

echo '<p><label for="description"><span style="color: red">Description</span>:</label>';
echo form_textarea(array('id' => 'description', 'name' => 'description', 'rows' => 20, 'cols' => '40', 'value' => $this->validation->description));
echo '</p>';

echo '<p><label for="to_apply"><span style="color: red">How to Apply</span></label>';
echo form_input(array('id' => 'to_apply', 'name' => 'to_apply', 'value' => $this->validation->to_apply));
echo '<br />Example: E-Mail or URL (Contact info!)';
echo '</p>';

echo '<div style="margin-left: 162px;">';
echo form_submit('add', 'Add this Job!');
echo '</div>';
echo form_close();


Messages In This Thread
Issue with Validation library - by El Forum - 07-11-2008, 04:42 AM
Issue with Validation library - by El Forum - 07-11-2008, 04:45 AM
Issue with Validation library - by El Forum - 07-11-2008, 05:01 AM
Issue with Validation library - by El Forum - 07-11-2008, 12:00 PM
Issue with Validation library - by El Forum - 07-13-2008, 11:45 PM
Issue with Validation library - by El Forum - 07-14-2008, 03:46 AM
Issue with Validation library - by El Forum - 07-14-2008, 06:02 AM
Issue with Validation library - by El Forum - 07-14-2008, 06:22 AM
Issue with Validation library - by El Forum - 07-14-2008, 07:02 AM
Issue with Validation library - by El Forum - 07-14-2008, 07:03 AM
Issue with Validation library - by El Forum - 07-14-2008, 07:09 AM
Issue with Validation library - by El Forum - 07-14-2008, 07:22 AM
Issue with Validation library - by El Forum - 07-14-2008, 07:57 AM
Issue with Validation library - by El Forum - 07-14-2008, 07:17 PM
Issue with Validation library - by El Forum - 07-14-2008, 10:30 PM



Theme © iAndrew 2016 - Forum software by © MyBB