Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#73 2010-03-07 13:39:38

tgv
New Member
Registered: 2010-03-07
Posts: 3

Re: mem_form - Generic HTTP form processing

found a bug at around line 829

$is_valid = ($use_values_array && in_array($v, $values)) or (!$use_values_array && in_array($v, $items));

you should use “||” instead of “or” here:

$is_valid = ($use_values_array && in_array($v, $values)) || (!$use_values_array && in_array($v, $items));

in php “=” has higher priority than “or”, but lower than “||”.

Cheers, Kostya

Offline

#74 2010-03-07 15:29:28

Manfre
Plugin Author
From: North Carolina
Registered: 2004-05-22
Posts: 588
Website

Re: mem_form - Generic HTTP form processing

Kostya, you are mistaken about how PHP processes a line containing an ‘or’ and an assignment.

If you run the following code:

function print_true() { echo “true\n”; return true;
}
function print_false() { echo “false\n”; return false;
}

echo “Test 1:\n”;
$a = print_true() or print_false();
echo “result is $a”;

echo “\n\nTest 2:\n”;
$b = print_false() or print_true();
echo “result is $b”;

you will see the output:

Test 1:
true
result is 1

Test 2:
false
true
result is

Offline

#75 2010-03-07 16:32:10

tgv
New Member
Registered: 2010-03-07
Posts: 3

Re: mem_form - Generic HTTP form processing

Exactly. That’s why before the fix I received “The value … is invalid for the input field …” message for every mem_form_select with just “items” and no “values”.

Offline

#76 2010-03-09 00:24:07

tgv
New Member
Registered: 2010-03-07
Posts: 3

Re: mem_form - Generic HTTP form processing

Another fix.

To make mem_form_select actually respect “required” attribute, at around line 822 replace

if (!empty($selected))

with

if (!empty($value)) or shorter if ($value).

Because an array with one empty element is not empty.

Cheers,
Kostya

Offline

#77 2010-03-10 16:38:33

datorhaexa
Member
From: Düsseldorf, Germany
Registered: 2005-05-23
Posts: 115
Website

Re: mem_form - Generic HTTP form processing

I must be doing something quite wrong as regardless of what tags I add, I get a constant
Textpattern Warning: tag does not exist on line 1120

I am using the latest downloadable v.0.6 and TXP v.4.2.0

Btw, does anyone know if there is a plug-in that would allow the sending of email attached files through a form on the site? ZCR does not do that, as far as I know.

Offline

#78 2010-04-21 02:07:15

jeroenvg
Member
From: netherlands
Registered: 2010-04-21
Posts: 34

Re: mem_form - Generic HTTP form processing

is it possible to make a radio group required; meaning at least one option must be selected for the form to submit?

Offline

#79 2010-04-27 17:20:38

jeroenvg
Member
From: netherlands
Registered: 2010-04-21
Posts: 34

Re: mem_form - Generic HTTP form processing

how would i go about translating mem_form’s (error) messages – the mem_form_lang array? can i do this with a callback hooking into mem_form? do i need the MLP plugin?

(i’m new to textpattern, and looking for examples)

Offline

#80 2010-05-05 17:09:40

jeroenvg
Member
From: netherlands
Registered: 2010-04-21
Posts: 34

Re: mem_form - Generic HTTP form processing

jeroenvg wrote:

how would i go about translating mem_form’s (error) messages – the mem_form_lang array? can i do this with a callback hooking into mem_form? do i need the MLP plugin?

AFAICT, overriding the array from my own plugin is not how this is supposed to work:

// translate mem_form messages
register_callback('jvg_l10n', 'mem_form.defaults');
function jvg_l10n() {
	$mem_self_lang = array(
		'<index>' => '<dutch translation>',
		...
	);
}

Offline

#81 2010-05-05 18:11:25

jeroenvg
Member
From: netherlands
Registered: 2010-04-21
Posts: 34

Re: mem_form - Generic HTTP form processing

i’m trying to parse a mem_form_hidden value from my own fields, using mem_form_value, like this:

...
    <txp:mem_form_hidden
name="RealName"
required="0"
value='<txp:mem_form_value name="firstName" /> <txp:mem_form_value name="lastName" />'
    />
...
    <txp:mem_form_text
break=": "
label="Last name"
name="lastName"
required="1"
    />
    <txp:mem_form_text
break=": "
label="First name"
name="firstName"
required="1"
    />
...

but the value for RealName is always empty after submitting the form (both after a successful submit and one generating errors). am i doing something wrong?

Last edited by jeroenvg (2010-05-05 18:14:45)

Offline

#82 2010-06-02 01:49:30

jeroenvg
Member
From: netherlands
Registered: 2010-04-21
Posts: 34

Re: mem_form - Generic HTTP form processing

jeroenvg wrote:

i’m trying to parse a mem_form_hidden value from my own fields, using mem_form_value […]

that won’t work, probably due to security measures against angle brackets (<, >). it will work, though, with mem_form_secret, like this:

...
    <txp:mem_form_text
break=": "
label="Last name"
name="lastName"
required="1"
    />
    <txp:mem_form_text
break=": "
label="First name"
name="firstName"
required="1"
    />
...
    <txp:mem_form_secret
name="RealName"
value='<txp:mem_form_value name="firstName" /> <txp:mem_form_value name="lastName" />'
    />

(note the alternating single/ double quotes.)

Offline

#83 2010-06-18 01:49:36

Manfre
Plugin Author
From: North Carolina
Registered: 2004-05-22
Posts: 588
Website

Re: mem_form - Generic HTTP form processing

mem_form v0.8 released

Adds better support for custom field level validation and form level validation.

Offline

#84 2010-06-18 09:36:04

PascalL
Member
From: Switzerland
Registered: 2009-03-09
Posts: 132
Website

Re: mem_form - Generic HTTP form processing

Thanks a lot Manfre !

Pascal

Offline

Board footer

Powered by FluxBB