Tokyoj

Topic: Setting fields to required or not required

How can Apply Now fields be edited to be 'Required' or 'Not Required'?
I've been reviewing page_apply.php but what I'm doing isn't working.

---------------
Tokyoj
"You can't build a reputation on what you're going to do." (Henry Ford)
"Insanity is doing the same thing over and over, expecting different results." (Albert Einstein)

Chronos

Re: Setting fields to required or not required

You're looking at the correct page. Under the validation comment the script simply checks the content of the fields and if empty it applies something to $error. If that variable has any entries after running through all checks it gives the message.

More clear by example so:

Code:
    // validation
    if ($apply_name == '')
    {
        $errors['apply_name'] = $translations['apply']['name_error'];
    }

That simply says, if the name field is empty, add the error message for it that will be displayed at the end (making it required). Remove that check ( if ($whateverfield) { $errors... } ) and it won't be required. If the field has more validation (like must-be in the form of an email) it may need some more minor adjusting.

Member of Jobberbase Development Team - Implementation and Coding

Visit my Blog: ChronoScripts (JobberBase scripts, support and freelance)
JobBoards: Telefonisch Werk and Top Bijbaan

Tokyoj

Re: Setting fields to required or not required

Yep....that's exactly what I did...removed....

if ($apply_email == '')
    {
        $errors['apply_email'] = $translations['apply']['email_error'];
    }

but the field is still required.
What other "more minor adjusting" could there be?

---------------
Tokyoj
"You can't build a reputation on what you're going to do." (Henry Ford)
"Insanity is doing the same thing over and over, expecting different results." (Albert Einstein)

Chronos

Re: Setting fields to required or not required

In the case of email, there's another check (as I mentioned earlier, to see if its in the right format). It's the following bit of code (a bit below the other one):

Code:
                if (!validate_email($apply_email))

                {

                    $errors['apply_email'] = $translations['apply']['email_invalid'];

                }

Although removing it will make this field optional, it might give errors later in the process where the variable would be used (for example if the mailer would try to use it as senders address). Not sure about that though.

Last edited by Chronos (2009-02-10 18:12:51)

Member of Jobberbase Development Team - Implementation and Coding

Visit my Blog: ChronoScripts (JobberBase scripts, support and freelance)
JobBoards: Telefonisch Werk and Top Bijbaan

Tokyoj

Re: Setting fields to required or not required

Strange...but the only email validation related code in

page_apply.php is

if ($apply_email == '')
    {
        $errors['apply_email'] = $translations['apply']['email_error'];
    }

which was removed. Also for the field itself checked and did the following in

job-details.tpl

<input {if $smarty.session.apply_errors.apply_email}class="error"{/if} type="text" name="apply_email" id="apply_email" maxlength="50" size="30" value="{$smarty.session.apply_fields.apply_email}" />

<span class="validation-error">{if $smarty.session.apply_errors.apply_email}<img src="{$BASE_URL}img/icon-delete.png" alt="" />{/if}</span>    <span> &nbsp;&nbsp; {$translations.email.bcc}&nbsp;&nbsp;</span>

removed....

{if $smarty.session.apply_errors.apply_email}class="error"{/if}

and

<span class="validation-error">{if $smarty.session.apply_errors.apply_email}<img src="{$BASE_URL}img/icon-delete.png" alt="" />{/if}</span>   

and replaced

value="{$smarty.session.apply_fields.apply_email}"
with 
value="TESTING"

This pretty straight forward because I've done it with other programs...I'm probably just screwing up something simple.

---------------
Tokyoj
"You can't build a reputation on what you're going to do." (Henry Ford)
"Insanity is doing the same thing over and over, expecting different results." (Albert Einstein)

Chronos

Re: Setting fields to required or not required

The SMARTY code doesn't do any actual testing, it just displays errors if any exist. I'll take a look at the files tomorrow to see if there's any other mentioning.. though isn't the email pretty essential for an application?

Member of Jobberbase Development Team - Implementation and Coding

Visit my Blog: ChronoScripts (JobberBase scripts, support and freelance)
JobBoards: Telefonisch Werk and Top Bijbaan

Tokyoj

Re: Setting fields to required or not required

Yep...it is important, but not essential.
Most applicants will have their contact info in their application / resume.
That's why I'm interested in making it optional.
Thanks for your help...but it's not important enough for this much effort.

---------------
Tokyoj
"You can't build a reputation on what you're going to do." (Henry Ford)
"Insanity is doing the same thing over and over, expecting different results." (Albert Einstein)