For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > April 2006 > Re: [PEAR] Re: DB_Table QuickForm rules









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PEAR] Re: DB_Table QuickForm rules
Charlie van de Kerkhof

2006-04-20, 8:01 am

On 20 Apr 2006, at 14:16, Mark Wiesemann wrote:
Hi Mark


> I only had a quick look at your code -- but:
>
> Instead of using the second line of the code snippet from above
> $G_FORM =& $oBet->getForm(null, null, array('formName' => 'lab'));
> should do the trick as this also calls addRules() in
> Table/QuickForm.php. ('post' is not specified in the $args array
> because
> DB_Table uses 'post' as the default value for the method option of
> QF.)
>


But I don't want the whole form be the same elements. Some of them I
want to be grouped and there has to be a couple of other hidden input
elements present in the form. So to my knowledge getForm() is not an
option.

Do you have another suggestion?

Thnx!
- Charlie
Mark Wiesemann

2006-04-20, 8:01 am

Charlie van de Kerkhof wrote:

> But I don't want the whole form be the same elements. Some of them I
> want to be grouped and there has to be a couple of other hidden input
> elements present in the form. So to my knowledge getForm() is not an
> option.


You could also specify the column name as the first parameter of
getForm().

But it should be sufficient to call something like this:
DB_Table_QuickForm::addRules($G_FORM, $cols);
where $cols is $oBet->col reduced to the one column you want to use
here.
(If you use true as the fourth param of addRules(), the rule will be
also a client-side rule.)

Another note on your table definition:

> 'title' => array(
> 'type' => 'varchar',
> 'size' => 255,
> 'require' => true,
> 'qf_label' => 'Bet:',
> 'qf_type' => 'text',
> 'qf_attrs' => array('size' => 50),
> 'qf_rules' => array(
> 'required' => 'This field is required.'
> )


You specified both 'require' and 'qf_rules'/'required'. The last one
will also be automatically generated if it's not given. The message can
be customized via $GLOBALS['_DB_TABLE']['qf_rules']['requi
red'];
(see the comment in Table/QuickForm.php, line 24ff.) This might save you
some time if you have more than one field that is required.

Regards,
Mark
Charlie van de Kerkhof

2006-04-20, 8:01 am

On 20 Apr 2006, at 14:39, Mark Wiesemann wrote:
> Charlie van de Kerkhof wrote:
> You could also specify the column name as the first parameter of
> getForm().


Not working with the renderer I use.

> But it should be sufficient to call something like this:
> DB_Table_QuickForm::addRules($G_FORM, $cols);
> where $cols is $oBet->col reduced to the one column you want to use
> here.


I did the last one:
<<<
$element =& $oBet->getFormElement('title', 'vbet');
$G_FORM->addElement($element);
DB_Table_QuickForm::addRules($G_FORM, array($oBet->col['title']));

But unfortunately still no errors. Even if I add the fourth parameter
to it (clientside validation) it will not present me with an alert/
confirm message.
What I'm doing wrong?
[color=darkred]
> (If you use true as the fourth param of addRules(), the rule will be
> also a client-side rule.)
>
> Another note on your table definition:
> You specified both 'require' and 'qf_rules'/'required'. The last one
> will also be automatically generated if it's not given. The message
> can
> be customized via $GLOBALS['_DB_TABLE']['qf_rules']['requi
red'];
> (see the comment in Table/QuickForm.php, line 24ff.) This might
> save you
> some time if you have more than one field that is required.


Thanx for these notes. Always good to have. I saw in the comments in
the script.
It means if I don't define anything then these default issues will
work? Because these are fine! ;)

- Charlie
Mark Wiesemann

2006-04-20, 8:01 am

Hi Charlie,

> But unfortunately still no errors. Even if I add the fourth parameter to
> it (clientside validation) it will not present me with an alert/confirm
> message.
> What I'm doing wrong?


That's not easy to say without having your full code. Please do a
var_dump($G_FORM->_rules);
after calling addElement() (in QF) and addRules() (in DB_Table_QF).
Do you see the rule in the output? If yes, then it's a rendering
problem. If not, it's a DB_Table or DB_Table usage problem.

> Thanx for these notes. Always good to have. I saw in the comments in the
> script.
> It means if I don't define anything then these default issues will work?
> Because these are fine! ;)


Not sure, what you mean, but: If you only have 'require' => true in your
column array, a 'required' QF rule with 'The item %s is required.' as
error message will be added (%s is the field name). The message can be
customized (localized) via $GLOBALS.

Regards,
Mark
Charlie van de Kerkhof

2006-04-20, 8:01 am

On 20 Apr 2006, at 15:23, Mark Wiesemann wrote:
>
> That's not easy to say without having your full code. Please do a
> var_dump($G_FORM->_rules);
> after calling addElement() (in QF) and addRules() (in DB_Table_QF).
> Do you see the rule in the output? If yes, then it's a rendering
> problem. If not, it's a DB_Table or DB_Table usage problem.
>


hi Mark,

var_dump($G_FORM->_rules); = array(0). so now rules.

I give up! I tried a couple of PEAR packages for 5 days now and no
luck. Not even one custom form! Lack of documentation is a big BIG
problem.
But many thanks for all your help!!

Regards,
- Charlie
Mark Wiesemann

2006-04-20, 7:01 pm

Charlie van de Kerkhof wrote:

> var_dump($G_FORM->_rules); = array(0). so now rules.


You might want to give this a last try:
DB_Table_QuickForm::addRules($G_FORM, 'title' => $oBet->col['title']);
(that's what I meant with the restriction, in your code line the key got
lost but it is needed to find the right QF field)

And, as I said before, it is not easy to say where the problem is when I
can't test and debug the code.

> I give up! I tried a couple of PEAR packages for 5 days now and no
> luck. Not even one custom form! Lack of documentation is a big BIG
> problem.


Right, it is a problem. And anybody is invited to help improving this
situation. There were three or four people that offered help with
documentating DB_Table (or better said: updating the current docs in
Paul's wiki, moving to the contents to PEAR's manual), but I never heard
anything from them again. :-(

Regards,
Mark
bertrand Gugger

2006-04-20, 7:01 pm

Bonsoir,
Mark Wiesemann wrote:

>Charlie van de Kerkhof wrote:
>
>
>
>
>You might want to give this a last try:
> DB_Table_QuickForm::addRules($G_FORM, 'title' => $oBet->col['title']);
>(that's what I meant with the restriction, in your code line the key got
>lost but it is needed to find the right QF field)
>
>And, as I said before, it is not easy to say where the problem is when I
>can't test and debug the code.
>
>
>
I guess lack of knowledge in basic php and code is too.
[color=darkred]
>
>Right, it is a problem. And anybody is invited to help improving this
>situation. There were three or four people that offered help with
>documentating DB_Table (or better said: updating the current docs in
>Paul's wiki, moving to the contents to PEAR's manual), but I never heard
>anything from them again. :-(
>
>

I guess Charlie will help now , as free volunteer , as we are all.

Regards
--
toggg
Charlie van de Kerkhof

2006-04-20, 7:01 pm

On 20 Apr 2006, at 22:18, bertrand Gugger wrote:

> Bonsoir,
> I guess lack of knowledge in basic php and code is too.


If you had said 'lack of knowledge in advanced OOP' then I would
agree, but.. ;)
I think my expectations were a little too high. And a deadline is
knocking on my door...

> I guess Charlie will help now , as free volunteer , as we are all.


I agree! Would love to help. But I'm gonna say what everybody says:
'... When I finishe this project and have more time on my hands...' :)

regards,
- Charlie
Mark Wiesemann

2006-04-21, 4:01 am

bertrand Gugger wrote:

> I guess Charlie will help now , as free volunteer , as we are all.


No need anymore. Jon, one of the people that volunteered for helping
with the documentation (and also with the package itself), got in
contact with me again.

Regards,
Mark
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com