Topic: Extension - extract_elements

$form = extract_elements(array('dst', 'timezone', 'language', 'email_setting', 'save_pass', 'notify_with_post', 'auto_notify', 'time_format', 'date_format', 'disp_topics', 'disp_posts', 'show_smilies', 'show_img', 'show_img_sig', 'show_avatars', 'show_sig', 'style'));

($hook = get_hook('pf_change_details_settings_validation')) ? eval($hook) : null;


In the hook, how to add additional fields to the array for the extract_elements function? Thanks.

Re: Extension - extract_elements

Interesting point. We might want to change that array like we did with the calls to add_user, etc.

Re: Extension - extract_elements

this is how i did it

$form['new_field'] = $_POST['form']['new_field'];

Re: Extension - extract_elements

I am getting an "Undefined index" when the new field (checkbox) is unchecked. When the new field is hard coded into the array, then it works fine.

5 (edited by Gizzmo 2008-02-17 20:11)

Re: Extension - extract_elements

well make sure your html has the correct name tag. should look something like

name="form[new_field]"

Re: Extension - extract_elements

Yes it is.

Re: Extension - extract_elements

Gizzmo: I guess you have display_errors off on your server.
qubertman: Use an isset

Re: Extension - extract_elements

Smartys wrote:

qubertman: Use an isset

When the checkbox is unchecked and when saving, then the "Undefined index" error.

    <hook id="pf_change_details_settings_validation"><![CDATA[
        $form['show_online'] = $_POST['form']['show_online'];
        $form['show_online'] = (isset($form['show_online'])) ? 1 : 0;
    ]]></hook>


In viewtopic.php (line 472), there isn't a hook to change the icon status. I can get the text to display offline, but the icon is blue indicating online.

                    <div class="user<?php if ($cur_post['is_online'] == $cur_post['poster_id']) echo ' online' ?>">

FYI: Trying to convert the Hide User mod.

Re: Extension - extract_elements

Remove the first line in that hook. The second is the correct way.

Re: Extension - extract_elements

I meant use an isset on the POST value wink
And can't you just change $cur_post['is_online'] to NULL at vt_post_loop_start?

11

Re: Extension - extract_elements

if (isset($_POST['form']['new_field']))
{
    $form['new_field'] = $_POST['form']['new_field'];
}

Re: Extension - extract_elements

Got it! Thanks.

Re: Extension - extract_elements

Actually, I was thinking:

$form['new_field'] = isset($_POST['form']['new_field']) ? '1' : '0';

14

Re: Extension - extract_elements

It's more in keeping with that code he posted. Must admit, I did post without paying much attention to the previous posts. T'was just a quickie. big_smile

Re: Extension - extract_elements

It doesn't really make much of a difference, I just find the one-liner neater smile

16

Re: Extension - extract_elements

qubertman wrote:

When the checkbox is unchecked and when saving, then the "Undefined index" error.

yea i forgot check boxes return null when unchecked. when i had to do this, i was using a drop down list so it would always return 0,1, or 2.

Smartys wrote:

Actually, I was thinking:

$form['new_field'] = isset($_POST['form']['new_field']) ? '1' : '0';

yea id say that is the best way to do it.

17

Re: Extension - extract_elements

Smartys wrote:

It doesn't really make much of a difference, I just find the one-liner neater smile

Personally, I prefer the if clauses, (throwback to my preference of shell scripting), big_smile but your one liner is more in keeping with the code as written. Neater to keep things in style with the existing code. big_smile