Skip to content
This repository has been archived by the owner on Nov 26, 2020. It is now read-only.

Commit

Permalink
- updated dibi in examples
Browse files Browse the repository at this point in the history
- some improvements
  • Loading branch information
dg committed Oct 10, 2010
1 parent c126e36 commit 8bdfdee
Show file tree
Hide file tree
Showing 11 changed files with 800 additions and 168 deletions.
1 change: 0 additions & 1 deletion Akrabat.Forms/app/config.ini
Expand Up @@ -8,7 +8,6 @@ set.include_path = "%appDir%;%libsDir%"
database.driver = sqlite
database.file = "%modelsDir%/demo.db"
database.lazy = TRUE
database.resultObjects = TRUE

service.Nette-Security-IAuthenticator = Users

Expand Down
411 changes: 331 additions & 80 deletions Akrabat.Forms/libs/dibi.compact.php

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion Akrabat/app/config.ini
Expand Up @@ -8,7 +8,6 @@ set.include_path = "%appDir%;%libsDir%"
database.driver = sqlite
database.file = "%modelsDir%/demo.db"
database.lazy = TRUE
database.resultObjects = TRUE

service.Nette-Security-IAuthenticator = Users

Expand Down
411 changes: 331 additions & 80 deletions Akrabat/libs/dibi.compact.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Forms/example1.php
Expand Up @@ -105,7 +105,7 @@

// Step 2c: Check if form is valid
if ($form->isValid()) {
echo '<h2>And successfully validated!</h2>';
echo '<h2>Form was submitted and successfully validated</h2>';

$values = $form->getValues();
Debug::dump($values);
Expand Down
2 changes: 1 addition & 1 deletion Forms/example2.php
Expand Up @@ -131,7 +131,7 @@

// Step 2c: Check if form is valid
if ($form->isValid()) {
echo '<h2>And successfully validated!</h2>';
echo '<h2>Form was submitted and successfully validated</h2>';

$values = $form->getValues();
Debug::dump($values);
Expand Down
2 changes: 1 addition & 1 deletion Forms/example3.php
Expand Up @@ -136,7 +136,7 @@ public function translate($message, $plural = NULL)

// Step 2c: Check if form is valid
if ($form->isValid()) {
echo '<h2>And successfully validated!</h2>';
echo '<h2>Form was submitted and successfully validated</h2>';

$values = $form->getValues();
Debug::dump($values);
Expand Down
2 changes: 1 addition & 1 deletion Forms/example4.php
Expand Up @@ -145,7 +145,7 @@

// Step 2c: Check if form is valid
if ($form->isValid()) {
echo '<h2>And successfully validated!</h2>';
echo '<h2>Form was submitted and successfully validated</h2>';

$values = $form->getValues();
Debug::dump($values);
Expand Down
2 changes: 1 addition & 1 deletion Forms/example5.php
Expand Up @@ -44,7 +44,7 @@ function myValidator($item, $arg)

// Step 2c: Check if form is valid
if ($form->isValid()) {
echo '<h2>And successfully validated!</h2>';
echo '<h2>Form was submitted and successfully validated</h2>';

$values = $form->getValues();
Debug::dump($values);
Expand Down
2 changes: 1 addition & 1 deletion Forms/example6.php
Expand Up @@ -84,7 +84,7 @@

// Step 2c: Check if form is valid
if ($form->isValid()) {
echo '<h2>And successfully validated!</h2>';
echo '<h2>Form was submitted and successfully validated</h2>';

$values = $form->getValues();
Debug::dump($values);
Expand Down
132 changes: 132 additions & 0 deletions Forms/example7.php
@@ -0,0 +1,132 @@
<?php

/**
* Nette::Forms example 7
*
* - custom charset encoding (Forms internally works in UTF-8 encoding!)
*/


require_once '../../Nette/loader.php';

/*use Nette::Forms::Form;*/
/*use Nette::Debug;*/
/*use Nette::Web::Html;*/

Debug::enable();


$countries = array(
'Select your country',
'Europe' => array(
'CZ' => 'Česká republika',
'SK' => 'Slovakia',
),
'AU' => 'Australia',
'CA' => 'Canada',
'EG' => 'Egypt',
'JP' => 'Japan',
'US' => 'United States',
'?' => 'other',
);



// Step 1: Define form with validation rules
$form = new Form;
$form->encoding = 'ISO-8859-1';

// group Personal data
$form->addGroup('Personal data');
$form->addText('name', 'Your name:', 35);

$form->addSelect('country', 'Country:')
->skipFirst()
->setItems($countries, FALSE);

$form->addHidden('userid');

$form->addTextArea('note', 'Comment:', 30, 5);


// group for buttons
$form->addGroup();

$form->addSubmit('submit1', 'Send');






// Step 2: Check if form was submitted?
if ($form->isSubmitted()) {

// Step 2c: Check if form is valid
if ($form->isValid()) {
header('Content-type: text/html; charset=utf-8');

echo '<h2>Form was submitted and successfully validated</h2>';

$values = $form->getValues();
Debug::dump($values);

// this is the end, my friend :-)
exit;
}

} else {
// not submitted, define default values
$defaults = array(
'name' => 'Žluťoučký kůň',
'userid' => 'kůň',
'note' => 'жед',
'country' => 'Česká republika', // Czech Republic
);

$form->setDefaults($defaults);
}



// Step 3: Render form
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=<?= $form->encoding ?>" />
<meta http-equiv="content-language" content="en" />

<title>Nette::Forms example 7 | Nette Framework</title>

<style type="text/css">
<!--
.required {
color: darkred
}

fieldset {
padding: .5em;
margin: .3em 0;
background: #EAF3FA;
border: 1px solid #b2d1eb;
}

input.button {
font-size: 120%;
}

th {
width: 8em;
text-align: right;
}
-->
</style>
</head>

<body>
<h1>Nette::Forms example 7</h1>

<?php echo $form ?>
</body>
</html>

0 comments on commit 8bdfdee

Please sign in to comment.