PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
SOLVED: problems understanding grouped items, such as date

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> HTML
View previous topic :: View next topic  
Author Message
dgs



Joined: 13 May 2008
Posts: 20

PostPosted: Tue Jul 08, 2008 11:20 pm    Post subject: SOLVED: problems understanding grouped items, such as date Reply with quote

I am having problems figuring out how to get at the data that is in a group. I am including code that I have captured from several sources, but I don't know how to read the value.
Code:

<?php
require_once "HTML/QuickForm.php";

$form    = new HTML_QuickForm('frmTest', 'get');
$options = array('language' => 'en' , 'format' => 'Ymd' , 'minYear' => date('Y') - 1, 'maxYear' => date('Y') + 2);

$date_defaults = array(
        'Y' => date('Y'),
        'm' => date('m'),
        'd' => date('d'),
    );

$form->setDefaults(array('mydate' => $date_defaults));
$form->addElement('date', 'mydate', 'Choose date', $options);
$form->addElement('submit', 'btnSubmit', 'Submit');


if ($form->validate())
{
    // Form is validated, then processes the data
    $form->freeze();

    $data = $form->exportValues();

    $line = sprintf("%04d%02d%02d", $form->mydate['Y'], $form->mydate['m'], $form->mydate['d']);

    echo $line . "<br />";

    $form->process('process_data', false);
}
else
{
    $form->display();
}

function process_data($values)
{
    echo "<pre>";
    var_dump($values);
    echo "</pre>";
}
?>


When I process this, the var_dump works fine, but the value submitted for the $line is all zeros.


Last edited by dgs on Wed Jul 09, 2008 1:39 am; edited 1 time in total
Back to top
View user's profile Send private message
dgs



Joined: 13 May 2008
Posts: 20

PostPosted: Wed Jul 09, 2008 1:39 am    Post subject: Reply with quote

Ok, here is code that works. Embarassed Now I just need to figure out why in a program that I have created, a date element is not included correctly in the form. Crying or Very sad

Code:
<?php
require_once "HTML/QuickForm.php";

$form    = new HTML_QuickForm('frmTest', 'get');
$options = array('language' => 'en' , 'format' => 'Ymd' , 'minYear' => date('Y') - 1, 'maxYear' => date('Y') + 2);

$date_defaults = array(
        'Y' => date('Y'),
        'm' => date('m'),
        'd' => date('d'),
    );

$form->setDefaults(array('mydate' => $date_defaults));
$form->addElement('date', 'mydate', 'Choose date', $options);
$form->addElement('submit', 'btnSubmit', 'Submit');


if ($form->validate())
{
    // Form is validated, then processes the data
    $form->freeze();

    $data = $form->exportValues();

    $Y = $data['mydate']['Y'];
    $m = $data['mydate']['m'];
    $d = $data['mydate']['d'];

    echo "Y: " . $Y . "<br />";
    echo "m: " . $m . "<br />";
    echo "d: " . $d . "<br />";

    $line = sprintf("%04d%02d%02d", $Y, $m, $d);

    echo $line . "<br />";

    $form->process('process_data', false);
}
else
{
    $form->display();
}

function process_data($values)
{
    echo "<pre>";
    var_dump($values);
    echo "</pre>";
}
?>
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> HTML All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software