コード例 #1
0
 /**
  * Adds the specified component to the IComponentContainer.
  * @param  IComponent
  * @param  string
  * @param  string
  * @return void
  * @throws InvalidStateException
  */
 public function addComponent(IComponent $component, $name, $insertBefore = NULL)
 {
     parent::addComponent($component, $name, $insertBefore);
     if ($this->currentGroup !== NULL && $component instanceof IFormControl) {
         $this->currentGroup->add($component);
     }
 }
コード例 #2
0
ファイル: test.iterator.php プロジェクト: vrana/nette
<h1>Nette\Component iterator test</h1>

<pre>
<?php 
require_once '../../Nette/loader.php';
/*use Nette\Component;*/
/*use Nette\ComponentContainer;*/
/*use Nette\Forms\Button;*/
/*use Nette\Debug;*/
class ComponentX extends Component
{
}
$c = new ComponentContainer(NULL, 'top');
$c->addComponent(new ComponentContainer(), 'one');
$c->addComponent(new ComponentX(), 'two');
$c->addComponent(new Button('label'), 'button1');
$c->getComponent('one')->addComponent(new ComponentX(), 'inner');
$c->getComponent('one')->addComponent(new ComponentContainer(), 'inner2');
$c->getComponent('one')->getComponent('inner2')->addComponent(new Button('label'), 'button2');
echo "Normal:\n";
foreach ($c->getComponents() as $name => $component) {
    echo "{$name} [{$component->class}]\n";
}
echo "\n\n";
echo "Filter:\n";
foreach ($c->getComponents(FALSE, 'Nette\\Forms\\Button') as $name => $component) {
    echo "{$name} [{$component->class}]\n";
}
echo "\n\n";
echo "RecursiveIteratorIterator:\n";
foreach (new RecursiveIteratorIterator($c->getComponents(), 1) as $name => $component) {
コード例 #3
0
ファイル: test.namingContainer.php プロジェクト: vrana/nette
<h1>Nette\Forms naming container test</h1>

<?php 
require_once '../../Nette/loader.php';
/*use Nette\ComponentContainer;*/
/*use Nette\Forms\Form;*/
/*use Nette\Forms\TextInput;*/
/*use Nette\Forms\FormContainer;*/
/*use Nette\Debug;*/
Debug::enable();
$form = new Form();
$form->addText('name', 'Your name:', 35);
$sub = new ComponentContainer($form, 'container');
$sub->addComponent(new TextInput('First line'), 'text1');
$sub->addComponent(new TextInput('Second line'), 'text2');
$sub->addComponent($sub2 = new FormContainer(), 'formCont');
$sub2->addText('name', 'Your name:', 35);
$sub2->addText('age', 'Your age:', 5);
$sub = $form->addContainer('firstperson');
$sub->addText('name', 'Your name:', 35);
$sub->addText('age', 'Your age:', 5);
$sub = $form->addContainer('secondperson');
$sub->addText('name', 'Your name:', 35);
$sub->addText('age', 'Your age:', 5);
$sub->addFile('avatar', 'Picture:');
$form->addText('age', 'Your age:', 5);
$form->addSubmit('submit1', 'Send');
$_SERVER['REQUEST_METHOD'] = 'POST';
$_POST = array('name' => 'jim', 'text1' => 'hello', 'text2' => 'world', 'formCont' => array('name' => 'jack x\\\\y o\\\'connor', 'age' => '23'), 'firstperson' => array('name' => 'david', 'age' => '30'), 'secondperson' => array('name' => 'jim', 'age' => '40'), 'age' => '50');
$_FILES = array('secondperson' => array('name' => array('avatar' => 'license.txt'), 'type' => array('avatar' => 'text/plain'), 'tmp_name' => array('avatar' => 'C:\\PHP\\temp\\php1D5C.tmp'), 'error' => array('avatar' => 0), 'size' => array('avatar' => 3013)));
echo "Submitted?\n";